From 929b82b8f47ffae405a601a5ee6963a10644e73a Mon Sep 17 00:00:00 2001 From: STAM Date: Mon, 24 Jun 2024 01:15:44 +0300 Subject: [PATCH] Kaniko Build System --- CHANGELOG.md | 4 + Makefile | 17 +- .../roles/atlassian.bitbucket/files/Makefile | 23 +++ .../atlassian.bitbucket/files/kaniko-build.py | 194 ++++++++++++++++++ .../files/requirements.txt | 2 + .../roles/atlassian.jira/files/Makefile | 23 +++ .../atlassian.jira/files/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian.jira/files/requirements.txt | 2 + .../gurock.testrail/files/php70/ad/Makefile | 23 +++ .../files/php70/ad/kaniko-build.py | 194 ++++++++++++++++++ .../files/php70/ad/requirements.txt | 2 + .../gurock.testrail/files/php70/ldap/Makefile | 23 +++ .../files/php70/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../files/php70/ldap/requirements.txt | 2 + .../gurock.testrail/files/php70/main/Makefile | 23 +++ .../files/php70/main/kaniko-build.py | 194 ++++++++++++++++++ .../files/php70/main/requirements.txt | 2 + .../gurock.testrail/files/php71/ad/Makefile | 23 +++ .../files/php71/ad/kaniko-build.py | 194 ++++++++++++++++++ .../files/php71/ad/requirements.txt | 2 + .../gurock.testrail/files/php71/ldap/Makefile | 23 +++ .../files/php71/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../files/php71/ldap/requirements.txt | 2 + .../gurock.testrail/files/php71/main/Makefile | 23 +++ .../files/php71/main/kaniko-build.py | 194 ++++++++++++++++++ .../files/php71/main/requirements.txt | 2 + .../gurock.testrail/files/php72/ad/Makefile | 23 +++ .../files/php72/ad/kaniko-build.py | 194 ++++++++++++++++++ .../files/php72/ad/requirements.txt | 2 + .../gurock.testrail/files/php72/ldap/Makefile | 23 +++ .../files/php72/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../files/php72/ldap/requirements.txt | 2 + .../gurock.testrail/files/php72/main/Makefile | 23 +++ .../files/php72/main/kaniko-build.py | 194 ++++++++++++++++++ .../files/php72/main/requirements.txt | 2 + .../gurock.testrail/files/php74/ad/Makefile | 23 +++ .../files/php74/ad/kaniko-build.py | 194 ++++++++++++++++++ .../files/php74/ad/requirements.txt | 2 + .../gurock.testrail/files/php74/ldap/Makefile | 23 +++ .../files/php74/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../files/php74/ldap/requirements.txt | 2 + .../gurock.testrail/files/php74/main/Makefile | 23 +++ .../files/php74/main/kaniko-build.py | 194 ++++++++++++++++++ .../files/php74/main/requirements.txt | 2 + .../gurock.testrail/files/php81/ad/Makefile | 23 +++ .../files/php81/ad/kaniko-build.py | 194 ++++++++++++++++++ .../files/php81/ad/requirements.txt | 2 + .../gurock.testrail/files/php81/ldap/Makefile | 23 +++ .../files/php81/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../files/php81/ldap/requirements.txt | 2 + .../gurock.testrail/files/php81/main/Makefile | 23 +++ .../files/php81/main/kaniko-build.py | 194 ++++++++++++++++++ .../files/php81/main/requirements.txt | 2 + bin/kaniko/_deploy.py | 42 ++++ bin/kaniko/kaniko-build.py | 194 ++++++++++++++++++ bin/kaniko/requirements.txt | 2 + linux/advanced/mattermost/Makefile | 23 +++ linux/advanced/mattermost/kaniko-build.py | 194 ++++++++++++++++++ linux/advanced/mattermost/requirements.txt | 2 + linux/advanced/nextcloud/patched/14/Makefile | 23 +++ .../nextcloud/patched/14/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/14/requirements.txt | 2 + linux/advanced/nextcloud/patched/15/Makefile | 23 +++ .../nextcloud/patched/15/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/15/requirements.txt | 2 + linux/advanced/nextcloud/patched/16/Makefile | 23 +++ .../nextcloud/patched/16/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/16/requirements.txt | 2 + linux/advanced/nextcloud/patched/17/Makefile | 23 +++ .../nextcloud/patched/17/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/17/requirements.txt | 2 + linux/advanced/nextcloud/patched/18/Makefile | 23 +++ .../nextcloud/patched/18/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/18/requirements.txt | 2 + linux/advanced/nextcloud/patched/19/Makefile | 23 +++ .../nextcloud/patched/19/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/19/requirements.txt | 2 + linux/advanced/nextcloud/patched/20/Makefile | 23 +++ .../nextcloud/patched/20/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/20/requirements.txt | 2 + linux/advanced/nextcloud/patched/21/Makefile | 23 +++ .../nextcloud/patched/21/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/21/requirements.txt | 2 + linux/advanced/nextcloud/patched/22/Makefile | 23 +++ .../nextcloud/patched/22/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/22/requirements.txt | 2 + linux/advanced/nextcloud/patched/23/Makefile | 23 +++ .../nextcloud/patched/23/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/23/requirements.txt | 2 + linux/advanced/nextcloud/patched/24/Makefile | 23 +++ .../nextcloud/patched/24/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/24/requirements.txt | 2 + linux/advanced/nextcloud/patched/25/Makefile | 23 +++ .../nextcloud/patched/25/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/25/requirements.txt | 2 + linux/advanced/nextcloud/patched/26/Makefile | 23 +++ .../nextcloud/patched/26/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/26/requirements.txt | 2 + linux/advanced/nextcloud/patched/27/Makefile | 23 +++ .../nextcloud/patched/27/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/27/requirements.txt | 2 + linux/advanced/nextcloud/patched/28/Makefile | 23 +++ .../nextcloud/patched/28/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/28/requirements.txt | 2 + linux/advanced/nextcloud/patched/29/Makefile | 23 +++ .../nextcloud/patched/29/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/29/requirements.txt | 2 + .../nextcloud/patched/latest/Makefile | 23 +++ .../nextcloud/patched/latest/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/patched/latest/requirements.txt | 2 + linux/advanced/nextcloud/pure/14/Makefile | 23 +++ .../nextcloud/pure/14/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/14/requirements.txt | 2 + linux/advanced/nextcloud/pure/15/Makefile | 23 +++ .../nextcloud/pure/15/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/15/requirements.txt | 2 + linux/advanced/nextcloud/pure/16/Makefile | 23 +++ .../nextcloud/pure/16/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/16/requirements.txt | 2 + linux/advanced/nextcloud/pure/17/Makefile | 23 +++ .../nextcloud/pure/17/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/17/requirements.txt | 2 + linux/advanced/nextcloud/pure/18/Makefile | 23 +++ .../nextcloud/pure/18/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/18/requirements.txt | 2 + linux/advanced/nextcloud/pure/19/Makefile | 23 +++ .../nextcloud/pure/19/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/19/requirements.txt | 2 + linux/advanced/nextcloud/pure/20/Makefile | 23 +++ .../nextcloud/pure/20/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/20/requirements.txt | 2 + linux/advanced/nextcloud/pure/21/Makefile | 23 +++ .../nextcloud/pure/21/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/21/requirements.txt | 2 + linux/advanced/nextcloud/pure/22/Makefile | 23 +++ .../nextcloud/pure/22/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/22/requirements.txt | 2 + linux/advanced/nextcloud/pure/23/Makefile | 23 +++ .../nextcloud/pure/23/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/23/requirements.txt | 2 + linux/advanced/nextcloud/pure/24/Makefile | 23 +++ .../nextcloud/pure/24/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/24/requirements.txt | 2 + linux/advanced/nextcloud/pure/25/Makefile | 23 +++ .../nextcloud/pure/25/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/25/requirements.txt | 2 + linux/advanced/nextcloud/pure/26/Makefile | 23 +++ .../nextcloud/pure/26/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/26/requirements.txt | 2 + linux/advanced/nextcloud/pure/27/Makefile | 23 +++ .../nextcloud/pure/27/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/27/requirements.txt | 2 + linux/advanced/nextcloud/pure/28/Makefile | 23 +++ .../nextcloud/pure/28/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/28/requirements.txt | 2 + linux/advanced/nextcloud/pure/29/Makefile | 23 +++ .../nextcloud/pure/29/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/29/requirements.txt | 2 + linux/advanced/nextcloud/pure/latest/Makefile | 23 +++ .../nextcloud/pure/latest/kaniko-build.py | 194 ++++++++++++++++++ .../nextcloud/pure/latest/requirements.txt | 2 + linux/advanced/python/develop/2.7/Makefile | 23 +++ .../python/develop/2.7/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/2.7/requirements.txt | 2 + linux/advanced/python/develop/3.10/Makefile | 23 +++ .../python/develop/3.10/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.10/requirements.txt | 2 + linux/advanced/python/develop/3.11/Makefile | 23 +++ .../python/develop/3.11/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.11/requirements.txt | 2 + linux/advanced/python/develop/3.12/Makefile | 23 +++ .../python/develop/3.12/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.12/requirements.txt | 2 + linux/advanced/python/develop/3.13/Makefile | 23 +++ .../python/develop/3.13/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.13/requirements.txt | 2 + linux/advanced/python/develop/3.6/Makefile | 23 +++ .../python/develop/3.6/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.6/requirements.txt | 2 + linux/advanced/python/develop/3.7/Makefile | 23 +++ .../python/develop/3.7/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.7/requirements.txt | 2 + linux/advanced/python/develop/3.8/Makefile | 23 +++ .../python/develop/3.8/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.8/requirements.txt | 2 + linux/advanced/python/develop/3.9/Makefile | 23 +++ .../python/develop/3.9/kaniko-build.py | 194 ++++++++++++++++++ .../python/develop/3.9/requirements.txt | 2 + linux/advanced/python/main/2.7/Makefile | 23 +++ .../advanced/python/main/2.7/kaniko-build.py | 194 ++++++++++++++++++ .../advanced/python/main/2.7/requirements.txt | 2 + linux/advanced/python/main/3.10/Makefile | 23 +++ .../advanced/python/main/3.10/kaniko-build.py | 194 ++++++++++++++++++ .../python/main/3.10/requirements.txt | 2 + linux/advanced/python/main/3.11/Makefile | 23 +++ .../advanced/python/main/3.11/kaniko-build.py | 194 ++++++++++++++++++ .../python/main/3.11/requirements.txt | 2 + linux/advanced/python/main/3.12/Makefile | 23 +++ .../advanced/python/main/3.12/kaniko-build.py | 194 ++++++++++++++++++ .../python/main/3.12/requirements.txt | 2 + linux/advanced/python/main/3.13/Makefile | 23 +++ .../advanced/python/main/3.13/kaniko-build.py | 194 ++++++++++++++++++ .../python/main/3.13/requirements.txt | 2 + linux/advanced/python/main/3.6/Makefile | 23 +++ .../advanced/python/main/3.6/kaniko-build.py | 194 ++++++++++++++++++ .../advanced/python/main/3.6/requirements.txt | 2 + linux/advanced/python/main/3.7/Makefile | 23 +++ .../advanced/python/main/3.7/kaniko-build.py | 194 ++++++++++++++++++ .../advanced/python/main/3.7/requirements.txt | 2 + linux/advanced/python/main/3.8/Makefile | 23 +++ .../advanced/python/main/3.8/kaniko-build.py | 194 ++++++++++++++++++ .../advanced/python/main/3.8/requirements.txt | 2 + linux/advanced/python/main/3.9/Makefile | 23 +++ .../advanced/python/main/3.9/kaniko-build.py | 194 ++++++++++++++++++ .../advanced/python/main/3.9/requirements.txt | 2 + linux/advanced/redash/Makefile | 23 +++ linux/advanced/sentry/latest/Makefile | 23 +++ linux/advanced/sentry/latest/kaniko-build.py | 194 ++++++++++++++++++ linux/advanced/sentry/latest/requirements.txt | 2 + linux/advanced/teamcity/server/Makefile | 23 +++ .../advanced/teamcity/server/kaniko-build.py | 194 ++++++++++++++++++ .../advanced/teamcity/server/requirements.txt | 2 + .../advanced/vscode-server/amxx/1.10/Makefile | 23 +++ .../vscode-server/amxx/1.10/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/amxx/1.10/requirements.txt | 2 + .../advanced/vscode-server/amxx/1.9/Makefile | 23 +++ .../vscode-server/amxx/1.9/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/amxx/1.9/requirements.txt | 2 + linux/advanced/vscode-server/android/Makefile | 23 +++ .../vscode-server/android/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/android/requirements.txt | 2 + linux/advanced/vscode-server/cpp/Makefile | 23 +++ .../vscode-server/cpp/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/cpp/requirements.txt | 2 + linux/advanced/vscode-server/devops/Makefile | 23 +++ .../vscode-server/devops/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/devops/requirements.txt | 2 + linux/advanced/vscode-server/docker/Makefile | 23 +++ .../vscode-server/docker/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/docker/requirements.txt | 2 + .../vscode-server/dotnet-full/Makefile | 23 +++ .../vscode-server/dotnet-full/kaniko-build.py | 194 ++++++++++++++++++ .../dotnet-full/requirements.txt | 2 + linux/advanced/vscode-server/dotnet/Makefile | 23 +++ .../vscode-server/dotnet/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/dotnet/requirements.txt | 2 + linux/advanced/vscode-server/latest/Makefile | 23 +++ .../vscode-server/latest/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/latest/requirements.txt | 2 + linux/advanced/vscode-server/mono/Makefile | 23 +++ .../vscode-server/mono/kaniko-build.py | 194 ++++++++++++++++++ .../vscode-server/mono/requirements.txt | 2 + linux/advanced/zabbix/3.0/agent/Makefile | 23 +++ .../advanced/zabbix/3.0/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/agent/requirements.txt | 2 + .../advanced/zabbix/3.0/java-gateway/Makefile | 23 +++ .../zabbix/3.0/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/java-gateway/requirements.txt | 2 + .../advanced/zabbix/3.0/proxy-mysql/Makefile | 23 +++ .../zabbix/3.0/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/proxy-mysql/requirements.txt | 2 + .../zabbix/3.0/proxy-sqlite3/Makefile | 23 +++ .../zabbix/3.0/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/3.0/server-mysql/Makefile | 23 +++ .../zabbix/3.0/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/server-mysql/requirements.txt | 2 + .../advanced/zabbix/3.0/server-pgsql/Makefile | 23 +++ .../zabbix/3.0/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/3.0/snmptraps/Makefile | 23 +++ .../zabbix/3.0/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/3.0/web-mysql/Makefile | 23 +++ .../zabbix/3.0/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/3.0/web-pgsql/Makefile | 23 +++ .../zabbix/3.0/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/3.0/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/4.0/agent/Makefile | 23 +++ .../advanced/zabbix/4.0/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/agent/requirements.txt | 2 + .../advanced/zabbix/4.0/java-gateway/Makefile | 23 +++ .../zabbix/4.0/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/java-gateway/requirements.txt | 2 + .../advanced/zabbix/4.0/proxy-mysql/Makefile | 23 +++ .../zabbix/4.0/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/proxy-mysql/requirements.txt | 2 + .../zabbix/4.0/proxy-sqlite3/Makefile | 23 +++ .../zabbix/4.0/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/4.0/server-mysql/Makefile | 23 +++ .../zabbix/4.0/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/server-mysql/requirements.txt | 2 + .../advanced/zabbix/4.0/server-pgsql/Makefile | 23 +++ .../zabbix/4.0/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/4.0/snmptraps/Makefile | 23 +++ .../zabbix/4.0/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/4.0/web-mysql/Makefile | 23 +++ .../zabbix/4.0/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/4.0/web-pgsql/Makefile | 23 +++ .../zabbix/4.0/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/4.0/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/5.0/agent/Makefile | 23 +++ .../advanced/zabbix/5.0/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/agent/requirements.txt | 2 + linux/advanced/zabbix/5.0/agent2/Makefile | 23 +++ .../zabbix/5.0/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/agent2/requirements.txt | 2 + .../advanced/zabbix/5.0/java-gateway/Makefile | 23 +++ .../zabbix/5.0/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/java-gateway/requirements.txt | 2 + .../advanced/zabbix/5.0/proxy-mysql/Makefile | 23 +++ .../zabbix/5.0/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/proxy-mysql/requirements.txt | 2 + .../zabbix/5.0/proxy-sqlite3/Makefile | 23 +++ .../zabbix/5.0/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/5.0/server-mysql/Makefile | 23 +++ .../zabbix/5.0/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/server-mysql/requirements.txt | 2 + .../advanced/zabbix/5.0/server-pgsql/Makefile | 23 +++ .../zabbix/5.0/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/5.0/snmptraps/Makefile | 23 +++ .../zabbix/5.0/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/5.0/web-mysql/Makefile | 23 +++ .../zabbix/5.0/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/5.0/web-pgsql/Makefile | 23 +++ .../zabbix/5.0/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.0/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/5.2/agent/Makefile | 23 +++ .../advanced/zabbix/5.2/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/agent/requirements.txt | 2 + linux/advanced/zabbix/5.2/agent2/Makefile | 23 +++ .../zabbix/5.2/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/agent2/requirements.txt | 2 + .../advanced/zabbix/5.2/java-gateway/Makefile | 23 +++ .../zabbix/5.2/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/java-gateway/requirements.txt | 2 + .../advanced/zabbix/5.2/proxy-mysql/Makefile | 23 +++ .../zabbix/5.2/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/proxy-mysql/requirements.txt | 2 + .../zabbix/5.2/proxy-sqlite3/Makefile | 23 +++ .../zabbix/5.2/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/5.2/server-mysql/Makefile | 23 +++ .../zabbix/5.2/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/server-mysql/requirements.txt | 2 + .../advanced/zabbix/5.2/server-pgsql/Makefile | 23 +++ .../zabbix/5.2/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/5.2/snmptraps/Makefile | 23 +++ .../zabbix/5.2/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/5.2/web-mysql/Makefile | 23 +++ .../zabbix/5.2/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/5.2/web-pgsql/Makefile | 23 +++ .../zabbix/5.2/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.2/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/5.4/agent/Makefile | 23 +++ .../advanced/zabbix/5.4/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/agent/requirements.txt | 2 + linux/advanced/zabbix/5.4/agent2/Makefile | 23 +++ .../zabbix/5.4/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/agent2/requirements.txt | 2 + .../advanced/zabbix/5.4/java-gateway/Makefile | 23 +++ .../zabbix/5.4/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/java-gateway/requirements.txt | 2 + .../advanced/zabbix/5.4/proxy-mysql/Makefile | 23 +++ .../zabbix/5.4/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/proxy-mysql/requirements.txt | 2 + .../zabbix/5.4/proxy-sqlite3/Makefile | 23 +++ .../zabbix/5.4/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/5.4/server-mysql/Makefile | 23 +++ .../zabbix/5.4/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/server-mysql/requirements.txt | 2 + .../advanced/zabbix/5.4/server-pgsql/Makefile | 23 +++ .../zabbix/5.4/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/5.4/snmptraps/Makefile | 23 +++ .../zabbix/5.4/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/5.4/web-mysql/Makefile | 23 +++ .../zabbix/5.4/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/5.4/web-pgsql/Makefile | 23 +++ .../zabbix/5.4/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/5.4/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/6.0/agent/Makefile | 23 +++ .../advanced/zabbix/6.0/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/agent/requirements.txt | 2 + linux/advanced/zabbix/6.0/agent2/Makefile | 23 +++ .../zabbix/6.0/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/agent2/requirements.txt | 2 + .../advanced/zabbix/6.0/java-gateway/Makefile | 23 +++ .../zabbix/6.0/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/java-gateway/requirements.txt | 2 + .../advanced/zabbix/6.0/proxy-mysql/Makefile | 23 +++ .../zabbix/6.0/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/proxy-mysql/requirements.txt | 2 + .../zabbix/6.0/proxy-sqlite3/Makefile | 23 +++ .../zabbix/6.0/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/6.0/server-mysql/Makefile | 23 +++ .../zabbix/6.0/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/server-mysql/requirements.txt | 2 + .../advanced/zabbix/6.0/server-pgsql/Makefile | 23 +++ .../zabbix/6.0/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/6.0/snmptraps/Makefile | 23 +++ .../zabbix/6.0/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/6.0/web-mysql/Makefile | 23 +++ .../zabbix/6.0/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/6.0/web-pgsql/Makefile | 23 +++ .../zabbix/6.0/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.0/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/6.2/agent/Makefile | 23 +++ .../advanced/zabbix/6.2/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/agent/requirements.txt | 2 + linux/advanced/zabbix/6.2/agent2/Makefile | 23 +++ .../zabbix/6.2/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/agent2/requirements.txt | 2 + .../advanced/zabbix/6.2/java-gateway/Makefile | 23 +++ .../zabbix/6.2/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/java-gateway/requirements.txt | 2 + .../advanced/zabbix/6.2/proxy-mysql/Makefile | 23 +++ .../zabbix/6.2/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/proxy-mysql/requirements.txt | 2 + .../zabbix/6.2/proxy-sqlite3/Makefile | 23 +++ .../zabbix/6.2/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/6.2/server-mysql/Makefile | 23 +++ .../zabbix/6.2/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/server-mysql/requirements.txt | 2 + .../advanced/zabbix/6.2/server-pgsql/Makefile | 23 +++ .../zabbix/6.2/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/6.2/snmptraps/Makefile | 23 +++ .../zabbix/6.2/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/6.2/web-mysql/Makefile | 23 +++ .../zabbix/6.2/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/6.2/web-pgsql/Makefile | 23 +++ .../zabbix/6.2/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.2/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/6.4/agent/Makefile | 23 +++ .../advanced/zabbix/6.4/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/agent/requirements.txt | 2 + linux/advanced/zabbix/6.4/agent2/Makefile | 23 +++ .../zabbix/6.4/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/agent2/requirements.txt | 2 + .../advanced/zabbix/6.4/java-gateway/Makefile | 23 +++ .../zabbix/6.4/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/java-gateway/requirements.txt | 2 + .../advanced/zabbix/6.4/proxy-mysql/Makefile | 23 +++ .../zabbix/6.4/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/proxy-mysql/requirements.txt | 2 + .../zabbix/6.4/proxy-sqlite3/Makefile | 23 +++ .../zabbix/6.4/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/proxy-sqlite3/requirements.txt | 2 + .../advanced/zabbix/6.4/server-mysql/Makefile | 23 +++ .../zabbix/6.4/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/server-mysql/requirements.txt | 2 + .../advanced/zabbix/6.4/server-pgsql/Makefile | 23 +++ .../zabbix/6.4/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/server-pgsql/requirements.txt | 2 + linux/advanced/zabbix/6.4/snmptraps/Makefile | 23 +++ .../zabbix/6.4/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/snmptraps/requirements.txt | 2 + linux/advanced/zabbix/6.4/web-mysql/Makefile | 23 +++ .../zabbix/6.4/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/web-mysql/requirements.txt | 2 + linux/advanced/zabbix/6.4/web-pgsql/Makefile | 23 +++ .../zabbix/6.4/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/6.4/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/latest/agent/Makefile | 23 +++ .../zabbix/latest/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/latest/agent/requirements.txt | 2 + linux/advanced/zabbix/latest/agent2/Makefile | 23 +++ .../zabbix/latest/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/latest/agent2/requirements.txt | 2 + .../zabbix/latest/java-gateway/Makefile | 23 +++ .../latest/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../latest/java-gateway/requirements.txt | 2 + .../zabbix/latest/proxy-mysql/Makefile | 23 +++ .../zabbix/latest/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../latest/proxy-mysql/requirements.txt | 2 + .../zabbix/latest/proxy-sqlite3/Makefile | 23 +++ .../latest/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../latest/proxy-sqlite3/requirements.txt | 2 + .../zabbix/latest/server-mysql/Makefile | 23 +++ .../latest/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../latest/server-mysql/requirements.txt | 2 + .../zabbix/latest/server-pgsql/Makefile | 23 +++ .../latest/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../latest/server-pgsql/requirements.txt | 2 + .../advanced/zabbix/latest/snmptraps/Makefile | 23 +++ .../zabbix/latest/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/latest/snmptraps/requirements.txt | 2 + .../advanced/zabbix/latest/web-mysql/Makefile | 23 +++ .../zabbix/latest/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/latest/web-mysql/requirements.txt | 2 + .../advanced/zabbix/latest/web-pgsql/Makefile | 23 +++ .../zabbix/latest/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/latest/web-pgsql/requirements.txt | 2 + linux/advanced/zabbix/trunk/agent/Makefile | 23 +++ .../zabbix/trunk/agent/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/trunk/agent/requirements.txt | 2 + linux/advanced/zabbix/trunk/agent2/Makefile | 23 +++ .../zabbix/trunk/agent2/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/trunk/agent2/requirements.txt | 2 + .../zabbix/trunk/java-gateway/Makefile | 23 +++ .../zabbix/trunk/java-gateway/kaniko-build.py | 194 ++++++++++++++++++ .../trunk/java-gateway/requirements.txt | 2 + .../zabbix/trunk/proxy-mysql/Makefile | 23 +++ .../zabbix/trunk/proxy-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/trunk/proxy-mysql/requirements.txt | 2 + .../zabbix/trunk/proxy-sqlite3/Makefile | 23 +++ .../trunk/proxy-sqlite3/kaniko-build.py | 194 ++++++++++++++++++ .../trunk/proxy-sqlite3/requirements.txt | 2 + .../zabbix/trunk/server-mysql/Makefile | 23 +++ .../zabbix/trunk/server-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../trunk/server-mysql/requirements.txt | 2 + .../zabbix/trunk/server-pgsql/Makefile | 23 +++ .../zabbix/trunk/server-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../trunk/server-pgsql/requirements.txt | 2 + .../advanced/zabbix/trunk/snmptraps/Makefile | 23 +++ .../zabbix/trunk/snmptraps/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/trunk/snmptraps/requirements.txt | 2 + .../advanced/zabbix/trunk/web-mysql/Makefile | 23 +++ .../zabbix/trunk/web-mysql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/trunk/web-mysql/requirements.txt | 2 + .../advanced/zabbix/trunk/web-pgsql/Makefile | 23 +++ .../zabbix/trunk/web-pgsql/kaniko-build.py | 194 ++++++++++++++++++ .../zabbix/trunk/web-pgsql/requirements.txt | 2 + .../ecosystem/epicmorg/devel/jdk11/Makefile | 23 +++ .../epicmorg/devel/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/devel/jdk11/requirements.txt | 2 + .../ecosystem/epicmorg/devel/jdk16/Makefile | 23 +++ .../epicmorg/devel/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/devel/jdk16/requirements.txt | 2 + .../ecosystem/epicmorg/devel/jdk6/Makefile | 23 +++ .../epicmorg/devel/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/devel/jdk6/requirements.txt | 2 + .../ecosystem/epicmorg/devel/jdk7/Makefile | 23 +++ .../epicmorg/devel/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/devel/jdk7/requirements.txt | 2 + .../ecosystem/epicmorg/devel/jdk8/Makefile | 23 +++ .../epicmorg/devel/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/devel/jdk8/requirements.txt | 2 + .../ecosystem/epicmorg/devel/main/Makefile | 23 +++ .../epicmorg/devel/main/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/devel/main/requirements.txt | 2 + .../ecosystem/epicmorg/edge/jdk11/Makefile | 23 +++ .../epicmorg/edge/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/edge/jdk11/requirements.txt | 2 + .../ecosystem/epicmorg/edge/jdk16/Makefile | 23 +++ .../epicmorg/edge/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/edge/jdk16/requirements.txt | 2 + .../ecosystem/epicmorg/edge/jdk6/Makefile | 23 +++ .../epicmorg/edge/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/edge/jdk6/requirements.txt | 2 + .../ecosystem/epicmorg/edge/jdk7/Makefile | 23 +++ .../epicmorg/edge/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/edge/jdk7/requirements.txt | 2 + .../ecosystem/epicmorg/edge/jdk8/Makefile | 23 +++ .../epicmorg/edge/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/edge/jdk8/requirements.txt | 2 + .../ecosystem/epicmorg/edge/main/Makefile | 23 +++ .../epicmorg/edge/main/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/edge/main/requirements.txt | 2 + .../ecosystem/epicmorg/prod/jdk11/Makefile | 23 +++ .../epicmorg/prod/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/prod/jdk11/requirements.txt | 2 + .../ecosystem/epicmorg/prod/jdk16/Makefile | 23 +++ .../epicmorg/prod/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/prod/jdk16/requirements.txt | 2 + .../ecosystem/epicmorg/prod/jdk6/Makefile | 23 +++ .../epicmorg/prod/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/prod/jdk6/requirements.txt | 2 + .../ecosystem/epicmorg/prod/jdk7/Makefile | 23 +++ .../epicmorg/prod/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/prod/jdk7/requirements.txt | 2 + .../ecosystem/epicmorg/prod/jdk8/Makefile | 23 +++ .../epicmorg/prod/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/prod/jdk8/requirements.txt | 2 + .../ecosystem/epicmorg/prod/main/Makefile | 23 +++ .../epicmorg/prod/main/kaniko-build.py | 194 ++++++++++++++++++ .../epicmorg/prod/main/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.0/Makefile | 3 + .../freegpt-webui/1.0/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.0/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.1/Makefile | 3 + .../freegpt-webui/1.1/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.1/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.2/Makefile | 3 + .../freegpt-webui/1.2/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.2/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.3.1/Makefile | 3 + .../freegpt-webui/1.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.3.1/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.3.2/Makefile | 3 + .../freegpt-webui/1.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.3.2/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.3/Makefile | 3 + .../freegpt-webui/1.3/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.3/requirements.txt | 2 + .../ecosystem/freegpt-webui/1.4/Makefile | 3 + .../freegpt-webui/1.4/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/1.4/requirements.txt | 2 + .../ecosystem/freegpt-webui/latest/Makefile | 3 + .../freegpt-webui/latest/kaniko-build.py | 194 ++++++++++++++++++ .../freegpt-webui/latest/requirements.txt | 2 + .../ecosystem/syspass/sysPass/kaniko-build.py | 194 ++++++++++++++++++ .../syspass/sysPass/requirements.txt | 2 + linux/ecosystem/apache2/php5.5/Makefile | 23 +++ .../ecosystem/apache2/php5.5/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php5.5/requirements.txt | 2 + linux/ecosystem/apache2/php7.0/Makefile | 23 +++ .../ecosystem/apache2/php7.0/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php7.0/requirements.txt | 2 + linux/ecosystem/apache2/php7.1/Makefile | 23 +++ .../ecosystem/apache2/php7.1/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php7.1/requirements.txt | 2 + linux/ecosystem/apache2/php7.2/Makefile | 23 +++ .../ecosystem/apache2/php7.2/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php7.2/requirements.txt | 2 + linux/ecosystem/apache2/php7.3/Makefile | 23 +++ .../ecosystem/apache2/php7.3/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php7.3/requirements.txt | 2 + linux/ecosystem/apache2/php7.4/Makefile | 23 +++ .../ecosystem/apache2/php7.4/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php7.4/requirements.txt | 2 + linux/ecosystem/apache2/php8.0/Makefile | 23 +++ .../ecosystem/apache2/php8.0/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php8.0/requirements.txt | 2 + linux/ecosystem/apache2/php8.1/Makefile | 23 +++ .../ecosystem/apache2/php8.1/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php8.1/requirements.txt | 2 + linux/ecosystem/apache2/php8.2/Makefile | 23 +++ .../ecosystem/apache2/php8.2/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php8.2/requirements.txt | 2 + linux/ecosystem/apache2/php8.3/Makefile | 23 +++ .../ecosystem/apache2/php8.3/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/apache2/php8.3/requirements.txt | 2 + .../atlassian/bitbucket/1/1.0.3/Makefile | 23 +++ .../bitbucket/1/1.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/1/1.0.3/requirements.txt | 2 + .../atlassian/bitbucket/1/1.1.2/Makefile | 23 +++ .../bitbucket/1/1.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/1/1.1.2/requirements.txt | 2 + .../atlassian/bitbucket/1/1.2.1/Makefile | 23 +++ .../bitbucket/1/1.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/1/1.2.1/requirements.txt | 2 + .../atlassian/bitbucket/1/1.2.4/Makefile | 23 +++ .../bitbucket/1/1.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/1/1.2.4/requirements.txt | 2 + .../atlassian/bitbucket/1/1.3.1/Makefile | 23 +++ .../bitbucket/1/1.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/1/1.3.1/requirements.txt | 2 + .../atlassian/bitbucket/2/2.0.3/Makefile | 23 +++ .../bitbucket/2/2.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.0.3/requirements.txt | 2 + .../atlassian/bitbucket/2/2.1.2/Makefile | 23 +++ .../bitbucket/2/2.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.1.2/requirements.txt | 2 + .../atlassian/bitbucket/2/2.10.0/Makefile | 23 +++ .../bitbucket/2/2.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.10.0/requirements.txt | 2 + .../atlassian/bitbucket/2/2.10.1/Makefile | 23 +++ .../bitbucket/2/2.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.10.1/requirements.txt | 2 + .../atlassian/bitbucket/2/2.10.2/Makefile | 23 +++ .../bitbucket/2/2.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.10.2/requirements.txt | 2 + .../atlassian/bitbucket/2/2.10.3/Makefile | 23 +++ .../bitbucket/2/2.10.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.10.3/requirements.txt | 2 + .../atlassian/bitbucket/2/2.10.4/Makefile | 23 +++ .../bitbucket/2/2.10.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.10.4/requirements.txt | 2 + .../atlassian/bitbucket/2/2.10.5/Makefile | 23 +++ .../bitbucket/2/2.10.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.10.5/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.3/Makefile | 23 +++ .../bitbucket/2/2.11.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.3/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.4/Makefile | 23 +++ .../bitbucket/2/2.11.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.4/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.5/Makefile | 23 +++ .../bitbucket/2/2.11.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.5/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.6/Makefile | 23 +++ .../bitbucket/2/2.11.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.6/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.7/Makefile | 23 +++ .../bitbucket/2/2.11.7/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.7/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.8/Makefile | 23 +++ .../bitbucket/2/2.11.8/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.8/requirements.txt | 2 + .../atlassian/bitbucket/2/2.11.9/Makefile | 23 +++ .../bitbucket/2/2.11.9/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.11.9/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.0/Makefile | 23 +++ .../bitbucket/2/2.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.0/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.1/Makefile | 23 +++ .../bitbucket/2/2.12.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.1/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.2/Makefile | 23 +++ .../bitbucket/2/2.12.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.2/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.3/Makefile | 23 +++ .../bitbucket/2/2.12.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.3/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.4/Makefile | 23 +++ .../bitbucket/2/2.12.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.4/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.5/Makefile | 23 +++ .../bitbucket/2/2.12.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.5/requirements.txt | 2 + .../atlassian/bitbucket/2/2.12.6/Makefile | 23 +++ .../bitbucket/2/2.12.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.12.6/requirements.txt | 2 + .../atlassian/bitbucket/2/2.2.0/Makefile | 23 +++ .../bitbucket/2/2.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.2.0/requirements.txt | 2 + .../atlassian/bitbucket/2/2.3.1/Makefile | 23 +++ .../bitbucket/2/2.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.3.1/requirements.txt | 2 + .../atlassian/bitbucket/2/2.4.2/Makefile | 23 +++ .../bitbucket/2/2.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.4.2/requirements.txt | 2 + .../atlassian/bitbucket/2/2.5.4/Makefile | 23 +++ .../bitbucket/2/2.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.5.4/requirements.txt | 2 + .../atlassian/bitbucket/2/2.6.5/Makefile | 23 +++ .../bitbucket/2/2.6.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.6.5/requirements.txt | 2 + .../atlassian/bitbucket/2/2.7.6/Makefile | 23 +++ .../bitbucket/2/2.7.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.7.6/requirements.txt | 2 + .../atlassian/bitbucket/2/2.8.4/Makefile | 23 +++ .../bitbucket/2/2.8.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.8.4/requirements.txt | 2 + .../atlassian/bitbucket/2/2.8.5/Makefile | 23 +++ .../bitbucket/2/2.8.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.8.5/requirements.txt | 2 + .../atlassian/bitbucket/2/2.9.1/Makefile | 23 +++ .../bitbucket/2/2.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.9.1/requirements.txt | 2 + .../atlassian/bitbucket/2/2.9.2/Makefile | 23 +++ .../bitbucket/2/2.9.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.9.2/requirements.txt | 2 + .../atlassian/bitbucket/2/2.9.3/Makefile | 23 +++ .../bitbucket/2/2.9.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.9.3/requirements.txt | 2 + .../atlassian/bitbucket/2/2.9.4/Makefile | 23 +++ .../bitbucket/2/2.9.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.9.4/requirements.txt | 2 + .../atlassian/bitbucket/2/2.9.5/Makefile | 23 +++ .../bitbucket/2/2.9.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/2/2.9.5/requirements.txt | 2 + .../atlassian/bitbucket/3/3.0.1/Makefile | 23 +++ .../bitbucket/3/3.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.0.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.0.4/Makefile | 23 +++ .../bitbucket/3/3.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.0.4/requirements.txt | 2 + .../atlassian/bitbucket/3/3.0.5/Makefile | 23 +++ .../bitbucket/3/3.0.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.0.5/requirements.txt | 2 + .../atlassian/bitbucket/3/3.0.6/Makefile | 23 +++ .../bitbucket/3/3.0.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.0.6/requirements.txt | 2 + .../atlassian/bitbucket/3/3.0.7/Makefile | 23 +++ .../bitbucket/3/3.0.7/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.0.7/requirements.txt | 2 + .../atlassian/bitbucket/3/3.0.8/Makefile | 23 +++ .../bitbucket/3/3.0.8/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.0.8/requirements.txt | 2 + .../atlassian/bitbucket/3/3.1.0/Makefile | 23 +++ .../bitbucket/3/3.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.1.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.1.1/Makefile | 23 +++ .../bitbucket/3/3.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.1.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.1.3/Makefile | 23 +++ .../bitbucket/3/3.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.1.3/requirements.txt | 2 + .../atlassian/bitbucket/3/3.1.4/Makefile | 23 +++ .../bitbucket/3/3.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.1.4/requirements.txt | 2 + .../atlassian/bitbucket/3/3.1.5/Makefile | 23 +++ .../bitbucket/3/3.1.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.1.5/requirements.txt | 2 + .../atlassian/bitbucket/3/3.1.7/Makefile | 23 +++ .../bitbucket/3/3.1.7/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.1.7/requirements.txt | 2 + .../atlassian/bitbucket/3/3.10.0/Makefile | 23 +++ .../bitbucket/3/3.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.10.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.10.2/Makefile | 23 +++ .../bitbucket/3/3.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.10.2/requirements.txt | 2 + .../atlassian/bitbucket/3/3.10.3/Makefile | 23 +++ .../bitbucket/3/3.10.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.10.3/requirements.txt | 2 + .../atlassian/bitbucket/3/3.10.4/Makefile | 23 +++ .../bitbucket/3/3.10.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.10.4/requirements.txt | 2 + .../atlassian/bitbucket/3/3.11.0/Makefile | 23 +++ .../bitbucket/3/3.11.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.11.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.11.1/Makefile | 23 +++ .../bitbucket/3/3.11.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.11.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.11.2/Makefile | 23 +++ .../bitbucket/3/3.11.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.11.2/requirements.txt | 2 + .../atlassian/bitbucket/3/3.11.3/Makefile | 23 +++ .../bitbucket/3/3.11.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.11.3/requirements.txt | 2 + .../atlassian/bitbucket/3/3.11.4/Makefile | 23 +++ .../bitbucket/3/3.11.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.11.4/requirements.txt | 2 + .../atlassian/bitbucket/3/3.11.6/Makefile | 23 +++ .../bitbucket/3/3.11.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.11.6/requirements.txt | 2 + .../atlassian/bitbucket/3/3.2.0/Makefile | 23 +++ .../bitbucket/3/3.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.2.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.2.2/Makefile | 23 +++ .../bitbucket/3/3.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.2.2/requirements.txt | 2 + .../atlassian/bitbucket/3/3.2.4/Makefile | 23 +++ .../bitbucket/3/3.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.2.4/requirements.txt | 2 + .../atlassian/bitbucket/3/3.2.5/Makefile | 23 +++ .../bitbucket/3/3.2.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.2.5/requirements.txt | 2 + .../atlassian/bitbucket/3/3.2.7/Makefile | 23 +++ .../bitbucket/3/3.2.7/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.2.7/requirements.txt | 2 + .../atlassian/bitbucket/3/3.3.0/Makefile | 23 +++ .../bitbucket/3/3.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.3.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.3.1/Makefile | 23 +++ .../bitbucket/3/3.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.3.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.3.2/Makefile | 23 +++ .../bitbucket/3/3.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.3.2/requirements.txt | 2 + .../atlassian/bitbucket/3/3.3.3/Makefile | 23 +++ .../bitbucket/3/3.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.3.3/requirements.txt | 2 + .../atlassian/bitbucket/3/3.3.5/Makefile | 23 +++ .../bitbucket/3/3.3.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.3.5/requirements.txt | 2 + .../atlassian/bitbucket/3/3.4.0/Makefile | 23 +++ .../bitbucket/3/3.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.4.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.4.1/Makefile | 23 +++ .../bitbucket/3/3.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.4.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.4.3/Makefile | 23 +++ .../bitbucket/3/3.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.4.3/requirements.txt | 2 + .../atlassian/bitbucket/3/3.4.5/Makefile | 23 +++ .../bitbucket/3/3.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.4.5/requirements.txt | 2 + .../atlassian/bitbucket/3/3.5.0/Makefile | 23 +++ .../bitbucket/3/3.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.5.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.5.1/Makefile | 23 +++ .../bitbucket/3/3.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.5.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.6.0/Makefile | 23 +++ .../bitbucket/3/3.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.6.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.6.1/Makefile | 23 +++ .../bitbucket/3/3.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.6.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.7.0/Makefile | 23 +++ .../bitbucket/3/3.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.7.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.7.1/Makefile | 23 +++ .../bitbucket/3/3.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.7.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.7.2/Makefile | 23 +++ .../bitbucket/3/3.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.7.2/requirements.txt | 2 + .../atlassian/bitbucket/3/3.7.3/Makefile | 23 +++ .../bitbucket/3/3.7.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.7.3/requirements.txt | 2 + .../atlassian/bitbucket/3/3.7.4/Makefile | 23 +++ .../bitbucket/3/3.7.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.7.4/requirements.txt | 2 + .../atlassian/bitbucket/3/3.8.0/Makefile | 23 +++ .../bitbucket/3/3.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.8.0/requirements.txt | 2 + .../atlassian/bitbucket/3/3.8.1/Makefile | 23 +++ .../bitbucket/3/3.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.8.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.9.1/Makefile | 23 +++ .../bitbucket/3/3.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.9.1/requirements.txt | 2 + .../atlassian/bitbucket/3/3.9.2/Makefile | 23 +++ .../bitbucket/3/3.9.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/3/3.9.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.1/Makefile | 23 +++ .../bitbucket/4/4.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.2/Makefile | 23 +++ .../bitbucket/4/4.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.3/Makefile | 23 +++ .../bitbucket/4/4.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.4/Makefile | 23 +++ .../bitbucket/4/4.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.4/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.6/Makefile | 23 +++ .../bitbucket/4/4.0.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.6/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.7/Makefile | 23 +++ .../bitbucket/4/4.0.7/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.7/requirements.txt | 2 + .../atlassian/bitbucket/4/4.0.8/Makefile | 23 +++ .../bitbucket/4/4.0.8/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.0.8/requirements.txt | 2 + .../atlassian/bitbucket/4/4.1.0/Makefile | 23 +++ .../bitbucket/4/4.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.1.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.1.3/Makefile | 23 +++ .../bitbucket/4/4.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.1.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.1.4/Makefile | 23 +++ .../bitbucket/4/4.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.1.4/requirements.txt | 2 + .../atlassian/bitbucket/4/4.1.6/Makefile | 23 +++ .../bitbucket/4/4.1.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.1.6/requirements.txt | 2 + .../atlassian/bitbucket/4/4.10.0/Makefile | 23 +++ .../bitbucket/4/4.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.10.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.10.1/Makefile | 23 +++ .../bitbucket/4/4.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.10.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.10.2/Makefile | 23 +++ .../bitbucket/4/4.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.10.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.11.1/Makefile | 23 +++ .../bitbucket/4/4.11.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.11.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.11.2/Makefile | 23 +++ .../bitbucket/4/4.11.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.11.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.12.0/Makefile | 23 +++ .../bitbucket/4/4.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.12.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.12.1/Makefile | 23 +++ .../bitbucket/4/4.12.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.12.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.13.0/Makefile | 23 +++ .../bitbucket/4/4.13.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.13.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.13.1/Makefile | 23 +++ .../bitbucket/4/4.13.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.13.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.0/Makefile | 23 +++ .../bitbucket/4/4.14.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.1/Makefile | 23 +++ .../bitbucket/4/4.14.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.10/Makefile | 23 +++ .../bitbucket/4/4.14.10/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.10/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.11/Makefile | 23 +++ .../bitbucket/4/4.14.11/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.11/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.12/Makefile | 23 +++ .../bitbucket/4/4.14.12/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.12/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.2/Makefile | 23 +++ .../bitbucket/4/4.14.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.3/Makefile | 23 +++ .../bitbucket/4/4.14.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.4/Makefile | 23 +++ .../bitbucket/4/4.14.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.4/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.5/Makefile | 23 +++ .../bitbucket/4/4.14.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.5/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.6/Makefile | 23 +++ .../bitbucket/4/4.14.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.6/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.7/Makefile | 23 +++ .../bitbucket/4/4.14.7/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.7/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.8/Makefile | 23 +++ .../bitbucket/4/4.14.8/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.8/requirements.txt | 2 + .../atlassian/bitbucket/4/4.14.9/Makefile | 23 +++ .../bitbucket/4/4.14.9/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.14.9/requirements.txt | 2 + .../atlassian/bitbucket/4/4.2.0/Makefile | 23 +++ .../bitbucket/4/4.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.2.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.2.1/Makefile | 23 +++ .../bitbucket/4/4.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.2.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.2.2/Makefile | 23 +++ .../bitbucket/4/4.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.2.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.2.3/Makefile | 23 +++ .../bitbucket/4/4.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.2.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.3.0/Makefile | 23 +++ .../bitbucket/4/4.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.3.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.3.1/Makefile | 23 +++ .../bitbucket/4/4.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.3.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.3.2/Makefile | 23 +++ .../bitbucket/4/4.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.3.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.3.3/Makefile | 23 +++ .../bitbucket/4/4.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.3.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.4.0/Makefile | 23 +++ .../bitbucket/4/4.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.4.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.4.1/Makefile | 23 +++ .../bitbucket/4/4.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.4.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.4.2/Makefile | 23 +++ .../bitbucket/4/4.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.4.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.4.4/Makefile | 23 +++ .../bitbucket/4/4.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.4.4/requirements.txt | 2 + .../atlassian/bitbucket/4/4.5.1/Makefile | 23 +++ .../bitbucket/4/4.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.5.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.5.2/Makefile | 23 +++ .../bitbucket/4/4.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.5.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.5.3/Makefile | 23 +++ .../bitbucket/4/4.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.5.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.6.0/Makefile | 23 +++ .../bitbucket/4/4.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.6.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.6.1/Makefile | 23 +++ .../bitbucket/4/4.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.6.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.6.2/Makefile | 23 +++ .../bitbucket/4/4.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.6.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.6.3/Makefile | 23 +++ .../bitbucket/4/4.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.6.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.6.4/Makefile | 23 +++ .../bitbucket/4/4.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.6.4/requirements.txt | 2 + .../atlassian/bitbucket/4/4.7.1/Makefile | 23 +++ .../bitbucket/4/4.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.7.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.7.2/Makefile | 23 +++ .../bitbucket/4/4.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.7.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.0/Makefile | 23 +++ .../bitbucket/4/4.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.1/Makefile | 23 +++ .../bitbucket/4/4.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.1/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.2/Makefile | 23 +++ .../bitbucket/4/4.8.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.2/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.3/Makefile | 23 +++ .../bitbucket/4/4.8.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.3/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.4/Makefile | 23 +++ .../bitbucket/4/4.8.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.4/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.5/Makefile | 23 +++ .../bitbucket/4/4.8.5/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.5/requirements.txt | 2 + .../atlassian/bitbucket/4/4.8.6/Makefile | 23 +++ .../bitbucket/4/4.8.6/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.8.6/requirements.txt | 2 + .../atlassian/bitbucket/4/4.9.0/Makefile | 23 +++ .../bitbucket/4/4.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.9.0/requirements.txt | 2 + .../atlassian/bitbucket/4/4.9.1/Makefile | 23 +++ .../bitbucket/4/4.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/4/4.9.1/requirements.txt | 2 + .../atlassian/bitbucket/7/7.21.4/Makefile | 23 +++ .../bitbucket/7/7.21.4/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/7/7.21.4/requirements.txt | 2 + .../atlassian/bitbucket/8/8.0.0/Makefile | 23 +++ .../bitbucket/8/8.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.0.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.0.3/Makefile | 23 +++ .../bitbucket/8/8.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.0.3/requirements.txt | 2 + .../atlassian/bitbucket/8/8.1.0/Makefile | 23 +++ .../bitbucket/8/8.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.1.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.1.3/Makefile | 23 +++ .../bitbucket/8/8.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.1.3/requirements.txt | 2 + .../atlassian/bitbucket/8/8.12.0/Makefile | 23 +++ .../bitbucket/8/8.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.12.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.17.0/Makefile | 23 +++ .../bitbucket/8/8.17.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.17.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.2.0/Makefile | 23 +++ .../bitbucket/8/8.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.2.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.2.2/Makefile | 23 +++ .../bitbucket/8/8.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.2.2/requirements.txt | 2 + .../atlassian/bitbucket/8/8.3.0/Makefile | 23 +++ .../bitbucket/8/8.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.3.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.3.1/Makefile | 23 +++ .../bitbucket/8/8.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.3.1/requirements.txt | 2 + .../atlassian/bitbucket/8/8.3.2/Makefile | 23 +++ .../bitbucket/8/8.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.3.2/requirements.txt | 2 + .../atlassian/bitbucket/8/8.3.3/Makefile | 23 +++ .../bitbucket/8/8.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.3.3/requirements.txt | 2 + .../atlassian/bitbucket/8/8.4.0/Makefile | 23 +++ .../bitbucket/8/8.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.4.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.4.1/Makefile | 23 +++ .../bitbucket/8/8.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.4.1/requirements.txt | 2 + .../atlassian/bitbucket/8/8.4.2/Makefile | 23 +++ .../bitbucket/8/8.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.4.2/requirements.txt | 2 + .../atlassian/bitbucket/8/8.5.0/Makefile | 23 +++ .../bitbucket/8/8.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.5.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.5.1/Makefile | 23 +++ .../bitbucket/8/8.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.5.1/requirements.txt | 2 + .../atlassian/bitbucket/8/8.6.0/Makefile | 23 +++ .../bitbucket/8/8.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.6.0/requirements.txt | 2 + .../atlassian/bitbucket/8/8.6.1/Makefile | 23 +++ .../bitbucket/8/8.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.6.1/requirements.txt | 2 + .../atlassian/bitbucket/8/8.7.0/Makefile | 23 +++ .../bitbucket/8/8.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/8/8.7.0/requirements.txt | 2 + .../atlassian/bitbucket/latest/Makefile | 23 +++ .../bitbucket/latest/kaniko-build.py | 194 ++++++++++++++++++ .../bitbucket/latest/requirements.txt | 2 + .../confluence/6/6.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.1/requirements.txt | 2 + .../confluence/6/6.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.2/requirements.txt | 2 + .../confluence/6/6.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.3/requirements.txt | 2 + .../confluence/6/6.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.4/requirements.txt | 2 + .../confluence/6/6.0.5/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.5/requirements.txt | 2 + .../confluence/6/6.0.6/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.6/requirements.txt | 2 + .../confluence/6/6.0.7/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.0.7/requirements.txt | 2 + .../confluence/6/6.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.1.0/requirements.txt | 2 + .../confluence/6/6.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.1.1/requirements.txt | 2 + .../confluence/6/6.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.1.2/requirements.txt | 2 + .../confluence/6/6.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.1.3/requirements.txt | 2 + .../confluence/6/6.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.1.4/requirements.txt | 2 + .../confluence/6/6.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.10.0/requirements.txt | 2 + .../confluence/6/6.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.10.1/requirements.txt | 2 + .../confluence/6/6.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.10.2/requirements.txt | 2 + .../confluence/6/6.10.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.10.3/requirements.txt | 2 + .../confluence/6/6.11.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.11.0/requirements.txt | 2 + .../confluence/6/6.11.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.11.1/requirements.txt | 2 + .../confluence/6/6.11.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.11.2/requirements.txt | 2 + .../confluence/6/6.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.12.0/requirements.txt | 2 + .../confluence/6/6.12.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.12.1/requirements.txt | 2 + .../confluence/6/6.12.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.12.2/requirements.txt | 2 + .../confluence/6/6.12.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.12.3/requirements.txt | 2 + .../confluence/6/6.12.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.12.4/requirements.txt | 2 + .../confluence/6/6.13.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.0/requirements.txt | 2 + .../confluence/6/6.13.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.1/requirements.txt | 2 + .../confluence/6/6.13.10/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.10/requirements.txt | 2 + .../confluence/6/6.13.11/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.11/requirements.txt | 2 + .../confluence/6/6.13.12/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.12/requirements.txt | 2 + .../confluence/6/6.13.13/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.13/requirements.txt | 2 + .../confluence/6/6.13.15/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.15/requirements.txt | 2 + .../confluence/6/6.13.17/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.17/requirements.txt | 2 + .../confluence/6/6.13.18/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.18/requirements.txt | 2 + .../confluence/6/6.13.19/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.19/requirements.txt | 2 + .../confluence/6/6.13.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.2/requirements.txt | 2 + .../confluence/6/6.13.20/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.20/requirements.txt | 2 + .../confluence/6/6.13.21/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.21/requirements.txt | 2 + .../confluence/6/6.13.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.3/requirements.txt | 2 + .../confluence/6/6.13.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.4/requirements.txt | 2 + .../confluence/6/6.13.5/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.5/requirements.txt | 2 + .../confluence/6/6.13.6/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.6/requirements.txt | 2 + .../confluence/6/6.13.7/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.7/requirements.txt | 2 + .../confluence/6/6.13.8/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.8/requirements.txt | 2 + .../confluence/6/6.13.9/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.13.9/requirements.txt | 2 + .../confluence/6/6.14.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.14.0/requirements.txt | 2 + .../confluence/6/6.14.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.14.1/requirements.txt | 2 + .../confluence/6/6.14.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.14.2/requirements.txt | 2 + .../confluence/6/6.14.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.14.3/requirements.txt | 2 + .../confluence/6/6.15.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.1/requirements.txt | 2 + .../confluence/6/6.15.10/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.10/requirements.txt | 2 + .../confluence/6/6.15.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.2/requirements.txt | 2 + .../confluence/6/6.15.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.4/requirements.txt | 2 + .../confluence/6/6.15.6/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.6/requirements.txt | 2 + .../confluence/6/6.15.7/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.7/requirements.txt | 2 + .../confluence/6/6.15.8/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.8/requirements.txt | 2 + .../confluence/6/6.15.9/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.15.9/requirements.txt | 2 + .../confluence/6/6.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.2.0/requirements.txt | 2 + .../confluence/6/6.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.2.1/requirements.txt | 2 + .../confluence/6/6.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.2.2/requirements.txt | 2 + .../confluence/6/6.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.2.3/requirements.txt | 2 + .../confluence/6/6.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.2.4/requirements.txt | 2 + .../confluence/6/6.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.3.1/requirements.txt | 2 + .../confluence/6/6.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.3.2/requirements.txt | 2 + .../confluence/6/6.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.3.3/requirements.txt | 2 + .../confluence/6/6.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.3.4/requirements.txt | 2 + .../confluence/6/6.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.4.0/requirements.txt | 2 + .../confluence/6/6.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.4.1/requirements.txt | 2 + .../confluence/6/6.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.4.2/requirements.txt | 2 + .../confluence/6/6.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.4.3/requirements.txt | 2 + .../confluence/6/6.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.5.0/requirements.txt | 2 + .../confluence/6/6.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.5.1/requirements.txt | 2 + .../confluence/6/6.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.5.2/requirements.txt | 2 + .../confluence/6/6.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.5.3/requirements.txt | 2 + .../confluence/6/6.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.0/requirements.txt | 2 + .../confluence/6/6.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.1/requirements.txt | 2 + .../confluence/6/6.6.10/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.10/requirements.txt | 2 + .../confluence/6/6.6.11/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.11/requirements.txt | 2 + .../confluence/6/6.6.12/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.12/requirements.txt | 2 + .../confluence/6/6.6.13/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.13/requirements.txt | 2 + .../confluence/6/6.6.14/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.14/requirements.txt | 2 + .../confluence/6/6.6.15/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.15/requirements.txt | 2 + .../confluence/6/6.6.16/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.16/requirements.txt | 2 + .../confluence/6/6.6.17/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.17/requirements.txt | 2 + .../confluence/6/6.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.2/requirements.txt | 2 + .../confluence/6/6.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.3/requirements.txt | 2 + .../confluence/6/6.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.4/requirements.txt | 2 + .../confluence/6/6.6.5/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.5/requirements.txt | 2 + .../confluence/6/6.6.6/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.6/requirements.txt | 2 + .../confluence/6/6.6.7/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.7/requirements.txt | 2 + .../confluence/6/6.6.8/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.8/requirements.txt | 2 + .../confluence/6/6.6.9/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.6.9/requirements.txt | 2 + .../confluence/6/6.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.7.0/requirements.txt | 2 + .../confluence/6/6.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.7.1/requirements.txt | 2 + .../confluence/6/6.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.7.2/requirements.txt | 2 + .../confluence/6/6.7.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.7.3/requirements.txt | 2 + .../confluence/6/6.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.8.0/requirements.txt | 2 + .../confluence/6/6.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.8.1/requirements.txt | 2 + .../confluence/6/6.8.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.8.2/requirements.txt | 2 + .../confluence/6/6.8.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.8.3/requirements.txt | 2 + .../confluence/6/6.8.5/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.8.5/requirements.txt | 2 + .../confluence/6/6.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.9.0/requirements.txt | 2 + .../confluence/6/6.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.9.1/requirements.txt | 2 + .../confluence/6/6.9.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/6/6.9.3/requirements.txt | 2 + .../atlassian/confluence/7/7.19.0/Makefile | 23 +++ .../confluence/7/7.19.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.0/requirements.txt | 2 + .../atlassian/confluence/7/7.19.1/Makefile | 23 +++ .../confluence/7/7.19.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.1/requirements.txt | 2 + .../atlassian/confluence/7/7.19.16/Makefile | 23 +++ .../confluence/7/7.19.16/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.16/requirements.txt | 2 + .../atlassian/confluence/7/7.19.17/Makefile | 23 +++ .../confluence/7/7.19.17/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.17/requirements.txt | 2 + .../atlassian/confluence/7/7.19.18/Makefile | 23 +++ .../confluence/7/7.19.18/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.18/requirements.txt | 2 + .../atlassian/confluence/7/7.19.2/Makefile | 23 +++ .../confluence/7/7.19.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.2/requirements.txt | 2 + .../atlassian/confluence/7/7.19.3/Makefile | 23 +++ .../confluence/7/7.19.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.3/requirements.txt | 2 + .../atlassian/confluence/7/7.19.4/Makefile | 23 +++ .../confluence/7/7.19.4/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.19.4/requirements.txt | 2 + .../atlassian/confluence/7/7.20.0/Makefile | 23 +++ .../confluence/7/7.20.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.20.0/requirements.txt | 2 + .../atlassian/confluence/7/7.20.1/Makefile | 23 +++ .../confluence/7/7.20.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.20.1/requirements.txt | 2 + .../atlassian/confluence/7/7.20.2/Makefile | 23 +++ .../confluence/7/7.20.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.20.2/requirements.txt | 2 + .../atlassian/confluence/7/7.20.3/Makefile | 23 +++ .../confluence/7/7.20.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/7/7.20.3/requirements.txt | 2 + .../atlassian/confluence/8/8.0.0/Makefile | 23 +++ .../confluence/8/8.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.0.0/requirements.txt | 2 + .../atlassian/confluence/8/8.0.1/Makefile | 23 +++ .../confluence/8/8.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.0.1/requirements.txt | 2 + .../atlassian/confluence/8/8.0.2/Makefile | 23 +++ .../confluence/8/8.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.0.2/requirements.txt | 2 + .../atlassian/confluence/8/8.4.0/Makefile | 23 +++ .../confluence/8/8.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.4.0/requirements.txt | 2 + .../atlassian/confluence/8/8.5.3/Makefile | 23 +++ .../confluence/8/8.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.5.3/requirements.txt | 2 + .../atlassian/confluence/8/8.6.1/Makefile | 23 +++ .../confluence/8/8.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.6.1/requirements.txt | 2 + .../atlassian/confluence/8/8.7.2/Makefile | 23 +++ .../confluence/8/8.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/8/8.7.2/requirements.txt | 2 + .../atlassian/confluence/latest/Makefile | 23 +++ .../confluence/latest/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/latest/requirements.txt | 2 + .../atlassian/confluence/templates/5/Makefile | 23 +++ .../confluence/templates/5/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/templates/5/requirements.txt | 2 + .../atlassian/confluence/templates/6/Makefile | 23 +++ .../confluence/templates/6/kaniko-build.py | 194 ++++++++++++++++++ .../confluence/templates/6/requirements.txt | 2 + .../atlassian/crowd/5/5.1.1/Makefile | 23 +++ .../atlassian/crowd/5/5.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/crowd/5/5.1.1/requirements.txt | 2 + .../ecosystem/atlassian/crowd/latest/Makefile | 23 +++ .../atlassian/crowd/latest/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/crowd/latest/requirements.txt | 2 + .../crucible/1/1.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.0.3/requirements.txt | 2 + .../crucible/1/1.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.0.4/requirements.txt | 2 + .../atlassian/crucible/1/1.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/crucible/1/1.0/requirements.txt | 2 + .../crucible/1/1.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.1.1/requirements.txt | 2 + .../crucible/1/1.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.1.2/requirements.txt | 2 + .../crucible/1/1.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.1.3/requirements.txt | 2 + .../crucible/1/1.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.1.4/requirements.txt | 2 + .../atlassian/crucible/1/1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/crucible/1/1.1/requirements.txt | 2 + .../crucible/1/1.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.2.1/requirements.txt | 2 + .../crucible/1/1.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.2.2/requirements.txt | 2 + .../crucible/1/1.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.2.3/requirements.txt | 2 + .../atlassian/crucible/1/1.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/crucible/1/1.2/requirements.txt | 2 + .../crucible/1/1.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.5.1/requirements.txt | 2 + .../crucible/1/1.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.5.2/requirements.txt | 2 + .../crucible/1/1.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.5.3/requirements.txt | 2 + .../crucible/1/1.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.5.4/requirements.txt | 2 + .../atlassian/crucible/1/1.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/crucible/1/1.5/requirements.txt | 2 + .../crucible/1/1.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.0/requirements.txt | 2 + .../crucible/1/1.6.0Beta1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.0Beta1/requirements.txt | 2 + .../crucible/1/1.6.0Beta2/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.0Beta2/requirements.txt | 2 + .../crucible/1/1.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.1/requirements.txt | 2 + .../crucible/1/1.6.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.2.1/requirements.txt | 2 + .../crucible/1/1.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.2/requirements.txt | 2 + .../crucible/1/1.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.3/requirements.txt | 2 + .../crucible/1/1.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.4/requirements.txt | 2 + .../crucible/1/1.6.5.a/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.5.a/requirements.txt | 2 + .../crucible/1/1.6.5/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.5/requirements.txt | 2 + .../crucible/1/1.6.5a/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.5a/requirements.txt | 2 + .../crucible/1/1.6.6/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/1/1.6.6/requirements.txt | 2 + .../atlassian/crucible/templates/1/Makefile | 23 +++ .../crucible/templates/1/kaniko-build.py | 194 ++++++++++++++++++ .../crucible/templates/1/requirements.txt | 2 + .../2/2.0.0.B3/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.0.0.B3/requirements.txt | 2 + .../2/2.0.0.RC1/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.0.0.RC1/requirements.txt | 2 + .../2/2.0.0.RC2/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.0.0.RC2/requirements.txt | 2 + .../2/2.0.0.RC3/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.0.0.RC3/requirements.txt | 2 + .../fisheye-crucible/2/2.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.0/requirements.txt | 2 + .../fisheye-crucible/2/2.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.1/requirements.txt | 2 + .../fisheye-crucible/2/2.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.2/requirements.txt | 2 + .../fisheye-crucible/2/2.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.3/requirements.txt | 2 + .../fisheye-crucible/2/2.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.4/requirements.txt | 2 + .../fisheye-crucible/2/2.0.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.5/requirements.txt | 2 + .../fisheye-crucible/2/2.0.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.0.6/requirements.txt | 2 + .../2/2.1.0.M2cc/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.1.0.M2cc/requirements.txt | 2 + .../2/2.1.0.RC1/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.1.0.RC1/requirements.txt | 2 + .../fisheye-crucible/2/2.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.1.0/requirements.txt | 2 + .../fisheye-crucible/2/2.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.1.1/requirements.txt | 2 + .../fisheye-crucible/2/2.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.1.2/requirements.txt | 2 + .../fisheye-crucible/2/2.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.1.3/requirements.txt | 2 + .../fisheye-crucible/2/2.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.1.4/requirements.txt | 2 + .../fisheye-crucible/2/2.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.0/requirements.txt | 2 + .../fisheye-crucible/2/2.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.1/requirements.txt | 2 + .../fisheye-crucible/2/2.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.2/requirements.txt | 2 + .../fisheye-crucible/2/2.10.3/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.3/requirements.txt | 2 + .../fisheye-crucible/2/2.10.4/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.4/requirements.txt | 2 + .../fisheye-crucible/2/2.10.5/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.5/requirements.txt | 2 + .../fisheye-crucible/2/2.10.6/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.6/requirements.txt | 2 + .../fisheye-crucible/2/2.10.7/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.7/requirements.txt | 2 + .../fisheye-crucible/2/2.10.8/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.10.8/requirements.txt | 2 + .../fisheye-crucible/2/2.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.2.0/requirements.txt | 2 + .../fisheye-crucible/2/2.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.2.1/requirements.txt | 2 + .../fisheye-crucible/2/2.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.2.3/requirements.txt | 2 + .../fisheye-crucible/2/2.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.0/requirements.txt | 2 + .../fisheye-crucible/2/2.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.1/requirements.txt | 2 + .../fisheye-crucible/2/2.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.2/requirements.txt | 2 + .../fisheye-crucible/2/2.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.3/requirements.txt | 2 + .../fisheye-crucible/2/2.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.4/requirements.txt | 2 + .../fisheye-crucible/2/2.3.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.5/requirements.txt | 2 + .../fisheye-crucible/2/2.3.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.6/requirements.txt | 2 + .../fisheye-crucible/2/2.3.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.7/requirements.txt | 2 + .../fisheye-crucible/2/2.3.8/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.3.8/requirements.txt | 2 + .../fisheye-crucible/2/2.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.0/requirements.txt | 2 + .../fisheye-crucible/2/2.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.1/requirements.txt | 2 + .../fisheye-crucible/2/2.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.2/requirements.txt | 2 + .../fisheye-crucible/2/2.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.3/requirements.txt | 2 + .../fisheye-crucible/2/2.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.4/requirements.txt | 2 + .../fisheye-crucible/2/2.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.5/requirements.txt | 2 + .../fisheye-crucible/2/2.4.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.4.6/requirements.txt | 2 + .../fisheye-crucible/2/2.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.0/requirements.txt | 2 + .../fisheye-crucible/2/2.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.1/requirements.txt | 2 + .../fisheye-crucible/2/2.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.2/requirements.txt | 2 + .../fisheye-crucible/2/2.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.3/requirements.txt | 2 + .../fisheye-crucible/2/2.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.4/requirements.txt | 2 + .../fisheye-crucible/2/2.5.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.5/requirements.txt | 2 + .../fisheye-crucible/2/2.5.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.6/requirements.txt | 2 + .../fisheye-crucible/2/2.5.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.7/requirements.txt | 2 + .../fisheye-crucible/2/2.5.8/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.8/requirements.txt | 2 + .../fisheye-crucible/2/2.5.9/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.5.9/requirements.txt | 2 + .../fisheye-crucible/2/2.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.0/requirements.txt | 2 + .../fisheye-crucible/2/2.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.1/requirements.txt | 2 + .../fisheye-crucible/2/2.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.2/requirements.txt | 2 + .../fisheye-crucible/2/2.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.3/requirements.txt | 2 + .../fisheye-crucible/2/2.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.4/requirements.txt | 2 + .../fisheye-crucible/2/2.6.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.5/requirements.txt | 2 + .../fisheye-crucible/2/2.6.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.6/requirements.txt | 2 + .../fisheye-crucible/2/2.6.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.7/requirements.txt | 2 + .../fisheye-crucible/2/2.6.8/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.8/requirements.txt | 2 + .../fisheye-crucible/2/2.6.9/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.6.9/requirements.txt | 2 + .../2/2.7.0-EAP-1/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.0-EAP-1/requirements.txt | 2 + .../2/2.7.0-EAP-2/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.0-EAP-2/requirements.txt | 2 + .../fisheye-crucible/2/2.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.0/requirements.txt | 2 + .../fisheye-crucible/2/2.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.1/requirements.txt | 2 + .../fisheye-crucible/2/2.7.10/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.10/requirements.txt | 2 + .../fisheye-crucible/2/2.7.11/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.11/requirements.txt | 2 + .../fisheye-crucible/2/2.7.12/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.12/requirements.txt | 2 + .../fisheye-crucible/2/2.7.13/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.13/requirements.txt | 2 + .../fisheye-crucible/2/2.7.14/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.14/requirements.txt | 2 + .../fisheye-crucible/2/2.7.15/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.7.15/requirements.txt | 2 + .../fisheye-crucible/2/2.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.2/requirements.txt | 2 + .../fisheye-crucible/2/2.7.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.3/requirements.txt | 2 + .../fisheye-crucible/2/2.7.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.4/requirements.txt | 2 + .../fisheye-crucible/2/2.7.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.5/requirements.txt | 2 + .../fisheye-crucible/2/2.7.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.6/requirements.txt | 2 + .../fisheye-crucible/2/2.7.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.7/requirements.txt | 2 + .../fisheye-crucible/2/2.7.8/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.8/requirements.txt | 2 + .../fisheye-crucible/2/2.7.9/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.7.9/requirements.txt | 2 + .../2/2.8.0-m1/kaniko-build.py | 194 ++++++++++++++++++ .../2/2.8.0-m1/requirements.txt | 2 + .../fisheye-crucible/2/2.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.8.0/requirements.txt | 2 + .../fisheye-crucible/2/2.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.8.1/requirements.txt | 2 + .../fisheye-crucible/2/2.8.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.8.2/requirements.txt | 2 + .../fisheye-crucible/2/2.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.9.0/requirements.txt | 2 + .../fisheye-crucible/2/2.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.9.1/requirements.txt | 2 + .../fisheye-crucible/2/2.9.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/2/2.9.2/requirements.txt | 2 + .../fisheye-crucible/3/3.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.0.0/requirements.txt | 2 + .../fisheye-crucible/3/3.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.0.1/requirements.txt | 2 + .../fisheye-crucible/3/3.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.0.2/requirements.txt | 2 + .../fisheye-crucible/3/3.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.0.3/requirements.txt | 2 + .../fisheye-crucible/3/3.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.0.4/requirements.txt | 2 + .../fisheye-crucible/3/3.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.0/requirements.txt | 2 + .../fisheye-crucible/3/3.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.1/requirements.txt | 2 + .../fisheye-crucible/3/3.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.2/requirements.txt | 2 + .../fisheye-crucible/3/3.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.3/requirements.txt | 2 + .../fisheye-crucible/3/3.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.4/requirements.txt | 2 + .../fisheye-crucible/3/3.1.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.5/requirements.txt | 2 + .../fisheye-crucible/3/3.1.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.6/requirements.txt | 2 + .../fisheye-crucible/3/3.1.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.1.7/requirements.txt | 2 + .../fisheye-crucible/3/3.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../3/3.10.1/requirements.txt | 2 + .../fisheye-crucible/3/3.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../3/3.10.2/requirements.txt | 2 + .../fisheye-crucible/3/3.10.3/kaniko-build.py | 194 ++++++++++++++++++ .../3/3.10.3/requirements.txt | 2 + .../fisheye-crucible/3/3.10.4/kaniko-build.py | 194 ++++++++++++++++++ .../3/3.10.4/requirements.txt | 2 + .../fisheye-crucible/3/3.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.2.0/requirements.txt | 2 + .../fisheye-crucible/3/3.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.2.1/requirements.txt | 2 + .../fisheye-crucible/3/3.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.2.2/requirements.txt | 2 + .../fisheye-crucible/3/3.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.2.3/requirements.txt | 2 + .../fisheye-crucible/3/3.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.2.4/requirements.txt | 2 + .../fisheye-crucible/3/3.2.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.2.5/requirements.txt | 2 + .../fisheye-crucible/3/3.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.3.0/requirements.txt | 2 + .../fisheye-crucible/3/3.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.3.1/requirements.txt | 2 + .../fisheye-crucible/3/3.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.3.2/requirements.txt | 2 + .../fisheye-crucible/3/3.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.3.3/requirements.txt | 2 + .../fisheye-crucible/3/3.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.3.4/requirements.txt | 2 + .../fisheye-crucible/3/3.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.4.0/requirements.txt | 2 + .../fisheye-crucible/3/3.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.4.3/requirements.txt | 2 + .../fisheye-crucible/3/3.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.4.4/requirements.txt | 2 + .../fisheye-crucible/3/3.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.4.5/requirements.txt | 2 + .../fisheye-crucible/3/3.4.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.4.6/requirements.txt | 2 + .../fisheye-crucible/3/3.4.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.4.7/requirements.txt | 2 + .../fisheye-crucible/3/3.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.5.0/requirements.txt | 2 + .../fisheye-crucible/3/3.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.5.1/requirements.txt | 2 + .../fisheye-crucible/3/3.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.5.2/requirements.txt | 2 + .../fisheye-crucible/3/3.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.5.3/requirements.txt | 2 + .../fisheye-crucible/3/3.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.5.4/requirements.txt | 2 + .../fisheye-crucible/3/3.5.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.5.5/requirements.txt | 2 + .../fisheye-crucible/3/3.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.6.0/requirements.txt | 2 + .../fisheye-crucible/3/3.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.6.1/requirements.txt | 2 + .../fisheye-crucible/3/3.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.6.2/requirements.txt | 2 + .../fisheye-crucible/3/3.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.6.3/requirements.txt | 2 + .../fisheye-crucible/3/3.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.6.4/requirements.txt | 2 + .../fisheye-crucible/3/3.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.7.0/requirements.txt | 2 + .../fisheye-crucible/3/3.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.7.1/requirements.txt | 2 + .../fisheye-crucible/3/3.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.8.0/requirements.txt | 2 + .../fisheye-crucible/3/3.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.8.1/requirements.txt | 2 + .../fisheye-crucible/3/3.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.9.0/requirements.txt | 2 + .../fisheye-crucible/3/3.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.9.1/requirements.txt | 2 + .../fisheye-crucible/3/3.9.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/3/3.9.2/requirements.txt | 2 + .../fisheye-crucible/4/4.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.0.2/requirements.txt | 2 + .../fisheye-crucible/4/4.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.0.3/requirements.txt | 2 + .../fisheye-crucible/4/4.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.0.4/requirements.txt | 2 + .../fisheye-crucible/4/4.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.1.0/requirements.txt | 2 + .../fisheye-crucible/4/4.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.1.1/requirements.txt | 2 + .../fisheye-crucible/4/4.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.1.2/requirements.txt | 2 + .../fisheye-crucible/4/4.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.1.3/requirements.txt | 2 + .../fisheye-crucible/4/4.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.2.0/requirements.txt | 2 + .../fisheye-crucible/4/4.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.2.1/requirements.txt | 2 + .../fisheye-crucible/4/4.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.2.2/requirements.txt | 2 + .../fisheye-crucible/4/4.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.2.3/requirements.txt | 2 + .../fisheye-crucible/4/4.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.3.0/requirements.txt | 2 + .../fisheye-crucible/4/4.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.3.1/requirements.txt | 2 + .../fisheye-crucible/4/4.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.3.2/requirements.txt | 2 + .../fisheye-crucible/4/4.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.3.3/requirements.txt | 2 + .../fisheye-crucible/4/4.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.0/requirements.txt | 2 + .../fisheye-crucible/4/4.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.1/requirements.txt | 2 + .../fisheye-crucible/4/4.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.2/requirements.txt | 2 + .../fisheye-crucible/4/4.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.3/requirements.txt | 2 + .../fisheye-crucible/4/4.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.5/requirements.txt | 2 + .../fisheye-crucible/4/4.4.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.6/requirements.txt | 2 + .../fisheye-crucible/4/4.4.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.4.7/requirements.txt | 2 + .../fisheye-crucible/4/4.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.5.0/requirements.txt | 2 + .../fisheye-crucible/4/4.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.5.1/requirements.txt | 2 + .../fisheye-crucible/4/4.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.5.2/requirements.txt | 2 + .../fisheye-crucible/4/4.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.5.3/requirements.txt | 2 + .../fisheye-crucible/4/4.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.5.4/requirements.txt | 2 + .../fisheye-crucible/4/4.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.6.0/requirements.txt | 2 + .../fisheye-crucible/4/4.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.6.1/requirements.txt | 2 + .../fisheye-crucible/4/4.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.7.0/requirements.txt | 2 + .../fisheye-crucible/4/4.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.7.1/requirements.txt | 2 + .../fisheye-crucible/4/4.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.7.2/requirements.txt | 2 + .../fisheye-crucible/4/4.7.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.7.3/requirements.txt | 2 + .../fisheye-crucible/4/4.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.0/requirements.txt | 2 + .../fisheye-crucible/4/4.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.1/requirements.txt | 2 + .../fisheye-crucible/4/4.8.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.2/requirements.txt | 2 + .../fisheye-crucible/4/4.8.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.3/requirements.txt | 2 + .../fisheye-crucible/4/4.8.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.4/requirements.txt | 2 + .../fisheye-crucible/4/4.8.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.5/requirements.txt | 2 + .../fisheye-crucible/4/4.8.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/4/4.8.6/requirements.txt | 2 + .../fisheye-crucible/latest/Makefile | 23 +++ .../fisheye-crucible/latest/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye-crucible/latest/requirements.txt | 2 + .../fisheye-crucible/templates/2/Makefile | 23 +++ .../templates/2/kaniko-build.py | 194 ++++++++++++++++++ .../templates/2/requirements.txt | 2 + .../fisheye-crucible/templates/3/Makefile | 23 +++ .../templates/3/kaniko-build.py | 194 ++++++++++++++++++ .../templates/3/requirements.txt | 2 + .../fisheye-crucible/templates/4/Makefile | 23 +++ .../templates/4/kaniko-build.py | 194 ++++++++++++++++++ .../templates/4/requirements.txt | 2 + .../fisheye/1/1.0.1a/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.0.1a/requirements.txt | 2 + .../atlassian/fisheye/1/1.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.1.3/requirements.txt | 2 + .../atlassian/fisheye/1/1.2.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.2.5/requirements.txt | 2 + .../atlassian/fisheye/1/1.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.3.3/requirements.txt | 2 + .../atlassian/fisheye/1/1.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.3.4/requirements.txt | 2 + .../atlassian/fisheye/1/1.3.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.3.5/requirements.txt | 2 + .../atlassian/fisheye/1/1.3.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.3.6/requirements.txt | 2 + .../atlassian/fisheye/1/1.3.7/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.3.7/requirements.txt | 2 + .../atlassian/fisheye/1/1.3.8/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.3.8/requirements.txt | 2 + .../atlassian/fisheye/1/1.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.4.1/requirements.txt | 2 + .../atlassian/fisheye/1/1.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.4.2/requirements.txt | 2 + .../atlassian/fisheye/1/1.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.4.3/requirements.txt | 2 + .../atlassian/fisheye/1/1.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/fisheye/1/1.4/requirements.txt | 2 + .../atlassian/fisheye/1/1.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.5.1/requirements.txt | 2 + .../atlassian/fisheye/1/1.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.5.2/requirements.txt | 2 + .../atlassian/fisheye/1/1.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.5.3/requirements.txt | 2 + .../atlassian/fisheye/1/1.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.5.4/requirements.txt | 2 + .../atlassian/fisheye/1/1.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/fisheye/1/1.5/requirements.txt | 2 + .../atlassian/fisheye/1/1.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.0/requirements.txt | 2 + .../fisheye/1/1.6.0Beta1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.0Beta1/requirements.txt | 2 + .../fisheye/1/1.6.0Beta2/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.0Beta2/requirements.txt | 2 + .../atlassian/fisheye/1/1.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.1/requirements.txt | 2 + .../atlassian/fisheye/1/1.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.3/requirements.txt | 2 + .../atlassian/fisheye/1/1.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.4/requirements.txt | 2 + .../fisheye/1/1.6.5.a/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.5.a/requirements.txt | 2 + .../atlassian/fisheye/1/1.6.5/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.5/requirements.txt | 2 + .../fisheye/1/1.6.5a/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.5a/requirements.txt | 2 + .../atlassian/fisheye/1/1.6.6/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/1/1.6.6/requirements.txt | 2 + .../atlassian/fisheye/templates/1/Makefile | 23 +++ .../fisheye/templates/1/kaniko-build.py | 194 ++++++++++++++++++ .../fisheye/templates/1/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.1.1/Makefile | 23 +++ .../atlassian/jira/4/4.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.1.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.1.2/Makefile | 23 +++ .../atlassian/jira/4/4.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.1.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.2.1/Makefile | 23 +++ .../atlassian/jira/4/4.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.2.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.2.2/Makefile | 23 +++ .../atlassian/jira/4/4.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.2.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.2.3/Makefile | 23 +++ .../atlassian/jira/4/4.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.2.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.2.4/Makefile | 23 +++ .../atlassian/jira/4/4.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.2.4/requirements.txt | 2 + linux/ecosystem/atlassian/jira/4/4.2/Makefile | 23 +++ .../atlassian/jira/4/4.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.3.1/Makefile | 23 +++ .../atlassian/jira/4/4.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.3.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.3.2/Makefile | 23 +++ .../atlassian/jira/4/4.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.3.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.3.3/Makefile | 23 +++ .../atlassian/jira/4/4.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.3.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.3.4/Makefile | 23 +++ .../atlassian/jira/4/4.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.3.4/requirements.txt | 2 + linux/ecosystem/atlassian/jira/4/4.3/Makefile | 23 +++ .../atlassian/jira/4/4.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.4.1/Makefile | 23 +++ .../atlassian/jira/4/4.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.4.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.4.3/Makefile | 23 +++ .../atlassian/jira/4/4.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.4.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.4.4/Makefile | 23 +++ .../atlassian/jira/4/4.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.4.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/4/4.4.5/Makefile | 23 +++ .../atlassian/jira/4/4.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.4.5/requirements.txt | 2 + linux/ecosystem/atlassian/jira/4/4.4/Makefile | 23 +++ .../atlassian/jira/4/4.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/4/4.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.1/Makefile | 23 +++ .../atlassian/jira/5/5.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.2/Makefile | 23 +++ .../atlassian/jira/5/5.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.3/Makefile | 23 +++ .../atlassian/jira/5/5.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.4/Makefile | 23 +++ .../atlassian/jira/5/5.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.5/Makefile | 23 +++ .../atlassian/jira/5/5.0.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.6/Makefile | 23 +++ .../atlassian/jira/5/5.0.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.0.7/Makefile | 23 +++ .../atlassian/jira/5/5.0.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0.7/requirements.txt | 2 + linux/ecosystem/atlassian/jira/5/5.0/Makefile | 23 +++ .../atlassian/jira/5/5.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.1/Makefile | 23 +++ .../atlassian/jira/5/5.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.2/Makefile | 23 +++ .../atlassian/jira/5/5.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.3/Makefile | 23 +++ .../atlassian/jira/5/5.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.4/Makefile | 23 +++ .../atlassian/jira/5/5.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.5/Makefile | 23 +++ .../atlassian/jira/5/5.1.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.6/Makefile | 23 +++ .../atlassian/jira/5/5.1.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.7/Makefile | 23 +++ .../atlassian/jira/5/5.1.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.1.8/Makefile | 23 +++ .../atlassian/jira/5/5.1.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1.8/requirements.txt | 2 + linux/ecosystem/atlassian/jira/5/5.1/Makefile | 23 +++ .../atlassian/jira/5/5.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.1/Makefile | 23 +++ .../atlassian/jira/5/5.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.1/requirements.txt | 2 + .../atlassian/jira/5/5.2.10/Makefile | 23 +++ .../atlassian/jira/5/5.2.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.10/requirements.txt | 2 + .../atlassian/jira/5/5.2.11/Makefile | 23 +++ .../atlassian/jira/5/5.2.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.11/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.2/Makefile | 23 +++ .../atlassian/jira/5/5.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.3/Makefile | 23 +++ .../atlassian/jira/5/5.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.3/requirements.txt | 2 + .../atlassian/jira/5/5.2.4.1/Makefile | 23 +++ .../atlassian/jira/5/5.2.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.4.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.4/Makefile | 23 +++ .../atlassian/jira/5/5.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.5/Makefile | 23 +++ .../atlassian/jira/5/5.2.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.6/Makefile | 23 +++ .../atlassian/jira/5/5.2.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.7/Makefile | 23 +++ .../atlassian/jira/5/5.2.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.8/Makefile | 23 +++ .../atlassian/jira/5/5.2.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/5/5.2.9/Makefile | 23 +++ .../atlassian/jira/5/5.2.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2.9/requirements.txt | 2 + linux/ecosystem/atlassian/jira/5/5.2/Makefile | 23 +++ .../atlassian/jira/5/5.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/5/5.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.1/Makefile | 23 +++ .../atlassian/jira/6/6.0.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.2/Makefile | 23 +++ .../atlassian/jira/6/6.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.3/Makefile | 23 +++ .../atlassian/jira/6/6.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.4/Makefile | 23 +++ .../atlassian/jira/6/6.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.5/Makefile | 23 +++ .../atlassian/jira/6/6.0.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.6/Makefile | 23 +++ .../atlassian/jira/6/6.0.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.7/Makefile | 23 +++ .../atlassian/jira/6/6.0.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.0.8/Makefile | 23 +++ .../atlassian/jira/6/6.0.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0.8/requirements.txt | 2 + linux/ecosystem/atlassian/jira/6/6.0/Makefile | 23 +++ .../atlassian/jira/6/6.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.1/Makefile | 23 +++ .../atlassian/jira/6/6.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.2/Makefile | 23 +++ .../atlassian/jira/6/6.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.3/Makefile | 23 +++ .../atlassian/jira/6/6.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.4/Makefile | 23 +++ .../atlassian/jira/6/6.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.5/Makefile | 23 +++ .../atlassian/jira/6/6.1.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.6/Makefile | 23 +++ .../atlassian/jira/6/6.1.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.7/Makefile | 23 +++ .../atlassian/jira/6/6.1.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.8/Makefile | 23 +++ .../atlassian/jira/6/6.1.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.1.9/Makefile | 23 +++ .../atlassian/jira/6/6.1.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1.9/requirements.txt | 2 + linux/ecosystem/atlassian/jira/6/6.1/Makefile | 23 +++ .../atlassian/jira/6/6.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.1/Makefile | 23 +++ .../atlassian/jira/6/6.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.2/Makefile | 23 +++ .../atlassian/jira/6/6.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.3/Makefile | 23 +++ .../atlassian/jira/6/6.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.4/Makefile | 23 +++ .../atlassian/jira/6/6.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.5/Makefile | 23 +++ .../atlassian/jira/6/6.2.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.6/Makefile | 23 +++ .../atlassian/jira/6/6.2.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.2.7/Makefile | 23 +++ .../atlassian/jira/6/6.2.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2.7/requirements.txt | 2 + linux/ecosystem/atlassian/jira/6/6.2/Makefile | 23 +++ .../atlassian/jira/6/6.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.1/Makefile | 23 +++ .../atlassian/jira/6/6.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.1/requirements.txt | 2 + .../atlassian/jira/6/6.3.10/Makefile | 23 +++ .../atlassian/jira/6/6.3.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.10/requirements.txt | 2 + .../atlassian/jira/6/6.3.11/Makefile | 23 +++ .../atlassian/jira/6/6.3.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.11/requirements.txt | 2 + .../atlassian/jira/6/6.3.12/Makefile | 23 +++ .../atlassian/jira/6/6.3.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.12/requirements.txt | 2 + .../atlassian/jira/6/6.3.13/Makefile | 23 +++ .../atlassian/jira/6/6.3.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.13/requirements.txt | 2 + .../atlassian/jira/6/6.3.14/Makefile | 23 +++ .../atlassian/jira/6/6.3.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.14/requirements.txt | 2 + .../atlassian/jira/6/6.3.15/Makefile | 23 +++ .../atlassian/jira/6/6.3.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.15/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.3/Makefile | 23 +++ .../atlassian/jira/6/6.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.4/Makefile | 23 +++ .../atlassian/jira/6/6.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.5/Makefile | 23 +++ .../atlassian/jira/6/6.3.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.6/Makefile | 23 +++ .../atlassian/jira/6/6.3.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.7/Makefile | 23 +++ .../atlassian/jira/6/6.3.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.8/Makefile | 23 +++ .../atlassian/jira/6/6.3.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.3.9/Makefile | 23 +++ .../atlassian/jira/6/6.3.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3.9/requirements.txt | 2 + linux/ecosystem/atlassian/jira/6/6.3/Makefile | 23 +++ .../atlassian/jira/6/6.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.1/Makefile | 23 +++ .../atlassian/jira/6/6.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.1/requirements.txt | 2 + .../atlassian/jira/6/6.4.10/Makefile | 23 +++ .../atlassian/jira/6/6.4.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.10/requirements.txt | 2 + .../atlassian/jira/6/6.4.11/Makefile | 23 +++ .../atlassian/jira/6/6.4.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.11/requirements.txt | 2 + .../atlassian/jira/6/6.4.12/Makefile | 23 +++ .../atlassian/jira/6/6.4.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.12/requirements.txt | 2 + .../atlassian/jira/6/6.4.13/Makefile | 23 +++ .../atlassian/jira/6/6.4.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.13/requirements.txt | 2 + .../atlassian/jira/6/6.4.14/Makefile | 23 +++ .../atlassian/jira/6/6.4.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.14/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.2/Makefile | 23 +++ .../atlassian/jira/6/6.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.3/Makefile | 23 +++ .../atlassian/jira/6/6.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.4/Makefile | 23 +++ .../atlassian/jira/6/6.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.5/Makefile | 23 +++ .../atlassian/jira/6/6.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.6/Makefile | 23 +++ .../atlassian/jira/6/6.4.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.7/Makefile | 23 +++ .../atlassian/jira/6/6.4.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.8/Makefile | 23 +++ .../atlassian/jira/6/6.4.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/6/6.4.9/Makefile | 23 +++ .../atlassian/jira/6/6.4.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4.9/requirements.txt | 2 + linux/ecosystem/atlassian/jira/6/6.4/Makefile | 23 +++ .../atlassian/jira/6/6.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/6/6.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.0.0/Makefile | 23 +++ .../atlassian/jira/7/7.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.0/requirements.txt | 2 + .../atlassian/jira/7/7.0.10/Makefile | 23 +++ .../atlassian/jira/7/7.0.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.10/requirements.txt | 2 + .../atlassian/jira/7/7.0.11/Makefile | 23 +++ .../atlassian/jira/7/7.0.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.11/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.0.2/Makefile | 23 +++ .../atlassian/jira/7/7.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.0.4/Makefile | 23 +++ .../atlassian/jira/7/7.0.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.0.5/Makefile | 23 +++ .../atlassian/jira/7/7.0.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.0.9/Makefile | 23 +++ .../atlassian/jira/7/7.0.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.0.9/requirements.txt | 2 + .../atlassian/jira/7/7.1.0-m01/Makefile | 23 +++ .../jira/7/7.1.0-m01/kaniko-build.py | 194 ++++++++++++++++++ .../jira/7/7.1.0-m01/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.0/Makefile | 23 +++ .../atlassian/jira/7/7.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.1/Makefile | 23 +++ .../atlassian/jira/7/7.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.1/requirements.txt | 2 + .../atlassian/jira/7/7.1.10/Makefile | 23 +++ .../atlassian/jira/7/7.1.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.10/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.2/Makefile | 23 +++ .../atlassian/jira/7/7.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.4/Makefile | 23 +++ .../atlassian/jira/7/7.1.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.6/Makefile | 23 +++ .../atlassian/jira/7/7.1.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.7/Makefile | 23 +++ .../atlassian/jira/7/7.1.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.8/Makefile | 23 +++ .../atlassian/jira/7/7.1.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.1.9/Makefile | 23 +++ .../atlassian/jira/7/7.1.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.1.9/requirements.txt | 2 + .../atlassian/jira/7/7.10.0/Makefile | 23 +++ .../atlassian/jira/7/7.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.10.0/requirements.txt | 2 + .../atlassian/jira/7/7.10.1/Makefile | 23 +++ .../atlassian/jira/7/7.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.10.1/requirements.txt | 2 + .../atlassian/jira/7/7.10.2/Makefile | 23 +++ .../atlassian/jira/7/7.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.10.2/requirements.txt | 2 + .../atlassian/jira/7/7.11.0/Makefile | 23 +++ .../atlassian/jira/7/7.11.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.11.0/requirements.txt | 2 + .../atlassian/jira/7/7.11.1/Makefile | 23 +++ .../atlassian/jira/7/7.11.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.11.1/requirements.txt | 2 + .../atlassian/jira/7/7.11.2/Makefile | 23 +++ .../atlassian/jira/7/7.11.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.11.2/requirements.txt | 2 + .../atlassian/jira/7/7.12.0/Makefile | 23 +++ .../atlassian/jira/7/7.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.12.0/requirements.txt | 2 + .../atlassian/jira/7/7.12.1/Makefile | 23 +++ .../atlassian/jira/7/7.12.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.12.1/requirements.txt | 2 + .../atlassian/jira/7/7.12.3/Makefile | 23 +++ .../atlassian/jira/7/7.12.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.12.3/requirements.txt | 2 + .../atlassian/jira/7/7.13.0/Makefile | 23 +++ .../atlassian/jira/7/7.13.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.0/requirements.txt | 2 + .../atlassian/jira/7/7.13.1/Makefile | 23 +++ .../atlassian/jira/7/7.13.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.1/requirements.txt | 2 + .../atlassian/jira/7/7.13.11/Makefile | 23 +++ .../atlassian/jira/7/7.13.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.11/requirements.txt | 2 + .../atlassian/jira/7/7.13.12/Makefile | 23 +++ .../atlassian/jira/7/7.13.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.12/requirements.txt | 2 + .../atlassian/jira/7/7.13.13/Makefile | 23 +++ .../atlassian/jira/7/7.13.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.13/requirements.txt | 2 + .../atlassian/jira/7/7.13.14/Makefile | 23 +++ .../atlassian/jira/7/7.13.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.14/requirements.txt | 2 + .../atlassian/jira/7/7.13.15/Makefile | 23 +++ .../atlassian/jira/7/7.13.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.15/requirements.txt | 2 + .../atlassian/jira/7/7.13.16/Makefile | 23 +++ .../atlassian/jira/7/7.13.16/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.16/requirements.txt | 2 + .../atlassian/jira/7/7.13.17/Makefile | 23 +++ .../atlassian/jira/7/7.13.17/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.17/requirements.txt | 2 + .../atlassian/jira/7/7.13.18/Makefile | 23 +++ .../atlassian/jira/7/7.13.18/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.18/requirements.txt | 2 + .../atlassian/jira/7/7.13.2/Makefile | 23 +++ .../atlassian/jira/7/7.13.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.2/requirements.txt | 2 + .../atlassian/jira/7/7.13.3/Makefile | 23 +++ .../atlassian/jira/7/7.13.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.3/requirements.txt | 2 + .../atlassian/jira/7/7.13.4/Makefile | 23 +++ .../atlassian/jira/7/7.13.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.4/requirements.txt | 2 + .../atlassian/jira/7/7.13.5/Makefile | 23 +++ .../atlassian/jira/7/7.13.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.5/requirements.txt | 2 + .../atlassian/jira/7/7.13.6/Makefile | 23 +++ .../atlassian/jira/7/7.13.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.6/requirements.txt | 2 + .../atlassian/jira/7/7.13.8/Makefile | 23 +++ .../atlassian/jira/7/7.13.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.8/requirements.txt | 2 + .../atlassian/jira/7/7.13.9/Makefile | 23 +++ .../atlassian/jira/7/7.13.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.13.9/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.0/Makefile | 23 +++ .../atlassian/jira/7/7.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.1/Makefile | 23 +++ .../atlassian/jira/7/7.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.1/requirements.txt | 2 + .../atlassian/jira/7/7.2.10/Makefile | 23 +++ .../atlassian/jira/7/7.2.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.10/requirements.txt | 2 + .../atlassian/jira/7/7.2.11/Makefile | 23 +++ .../atlassian/jira/7/7.2.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.11/requirements.txt | 2 + .../atlassian/jira/7/7.2.12/Makefile | 23 +++ .../atlassian/jira/7/7.2.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.12/requirements.txt | 2 + .../atlassian/jira/7/7.2.13/Makefile | 23 +++ .../atlassian/jira/7/7.2.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.13/requirements.txt | 2 + .../atlassian/jira/7/7.2.14/Makefile | 23 +++ .../atlassian/jira/7/7.2.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.14/requirements.txt | 2 + .../atlassian/jira/7/7.2.15/Makefile | 23 +++ .../atlassian/jira/7/7.2.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.15/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.2/Makefile | 23 +++ .../atlassian/jira/7/7.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.3/Makefile | 23 +++ .../atlassian/jira/7/7.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.4/Makefile | 23 +++ .../atlassian/jira/7/7.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.6/Makefile | 23 +++ .../atlassian/jira/7/7.2.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.7/Makefile | 23 +++ .../atlassian/jira/7/7.2.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.8/Makefile | 23 +++ .../atlassian/jira/7/7.2.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.2.9/Makefile | 23 +++ .../atlassian/jira/7/7.2.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.2.9/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.0/Makefile | 23 +++ .../atlassian/jira/7/7.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.1/Makefile | 23 +++ .../atlassian/jira/7/7.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.2/Makefile | 23 +++ .../atlassian/jira/7/7.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.3/Makefile | 23 +++ .../atlassian/jira/7/7.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.4/Makefile | 23 +++ .../atlassian/jira/7/7.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.5/Makefile | 23 +++ .../atlassian/jira/7/7.3.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.6/Makefile | 23 +++ .../atlassian/jira/7/7.3.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.7/Makefile | 23 +++ .../atlassian/jira/7/7.3.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.8/Makefile | 23 +++ .../atlassian/jira/7/7.3.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.3.9/Makefile | 23 +++ .../atlassian/jira/7/7.3.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.3.9/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.0/Makefile | 23 +++ .../atlassian/jira/7/7.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.1/Makefile | 23 +++ .../atlassian/jira/7/7.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.2/Makefile | 23 +++ .../atlassian/jira/7/7.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.3/Makefile | 23 +++ .../atlassian/jira/7/7.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.4/Makefile | 23 +++ .../atlassian/jira/7/7.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.5/Makefile | 23 +++ .../atlassian/jira/7/7.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.4.6/Makefile | 23 +++ .../atlassian/jira/7/7.4.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.4.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.5.0/Makefile | 23 +++ .../atlassian/jira/7/7.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.5.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.5.1/Makefile | 23 +++ .../atlassian/jira/7/7.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.5.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.5.2/Makefile | 23 +++ .../atlassian/jira/7/7.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.5.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.5.3/Makefile | 23 +++ .../atlassian/jira/7/7.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.5.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.5.4/Makefile | 23 +++ .../atlassian/jira/7/7.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.5.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.0/Makefile | 23 +++ .../atlassian/jira/7/7.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.1/Makefile | 23 +++ .../atlassian/jira/7/7.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.1/requirements.txt | 2 + .../atlassian/jira/7/7.6.10/Makefile | 23 +++ .../atlassian/jira/7/7.6.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.10/requirements.txt | 2 + .../atlassian/jira/7/7.6.11/Makefile | 23 +++ .../atlassian/jira/7/7.6.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.11/requirements.txt | 2 + .../atlassian/jira/7/7.6.12/Makefile | 23 +++ .../atlassian/jira/7/7.6.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.12/requirements.txt | 2 + .../atlassian/jira/7/7.6.13/Makefile | 23 +++ .../atlassian/jira/7/7.6.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.13/requirements.txt | 2 + .../atlassian/jira/7/7.6.14/Makefile | 23 +++ .../atlassian/jira/7/7.6.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.14/requirements.txt | 2 + .../atlassian/jira/7/7.6.15/Makefile | 23 +++ .../atlassian/jira/7/7.6.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.15/requirements.txt | 2 + .../atlassian/jira/7/7.6.16/Makefile | 23 +++ .../atlassian/jira/7/7.6.16/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.16/requirements.txt | 2 + .../atlassian/jira/7/7.6.17/Makefile | 23 +++ .../atlassian/jira/7/7.6.17/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.17/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.2/Makefile | 23 +++ .../atlassian/jira/7/7.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.3/Makefile | 23 +++ .../atlassian/jira/7/7.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.4/Makefile | 23 +++ .../atlassian/jira/7/7.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.6/Makefile | 23 +++ .../atlassian/jira/7/7.6.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.7/Makefile | 23 +++ .../atlassian/jira/7/7.6.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.8/Makefile | 23 +++ .../atlassian/jira/7/7.6.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.6.9/Makefile | 23 +++ .../atlassian/jira/7/7.6.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.6.9/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.7.0/Makefile | 23 +++ .../atlassian/jira/7/7.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.7.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.7.1/Makefile | 23 +++ .../atlassian/jira/7/7.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.7.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.7.2/Makefile | 23 +++ .../atlassian/jira/7/7.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.7.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.7.4/Makefile | 23 +++ .../atlassian/jira/7/7.7.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.7.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.8.0/Makefile | 23 +++ .../atlassian/jira/7/7.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.8.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.8.1/Makefile | 23 +++ .../atlassian/jira/7/7.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.8.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.8.2/Makefile | 23 +++ .../atlassian/jira/7/7.8.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.8.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.8.4/Makefile | 23 +++ .../atlassian/jira/7/7.8.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.8.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.9.0/Makefile | 23 +++ .../atlassian/jira/7/7.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.9.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/7/7.9.2/Makefile | 23 +++ .../atlassian/jira/7/7.9.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/7/7.9.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.0.0/Makefile | 23 +++ .../atlassian/jira/8/8.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.0.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.0.2/Makefile | 23 +++ .../atlassian/jira/8/8.0.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.0.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.0.3/Makefile | 23 +++ .../atlassian/jira/8/8.0.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.0.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.1.0/Makefile | 23 +++ .../atlassian/jira/8/8.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.1.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.1.1/Makefile | 23 +++ .../atlassian/jira/8/8.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.1.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.1.2/Makefile | 23 +++ .../atlassian/jira/8/8.1.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.1.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.1.3/Makefile | 23 +++ .../atlassian/jira/8/8.1.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.1.3/requirements.txt | 2 + .../atlassian/jira/8/8.10.0/Makefile | 23 +++ .../atlassian/jira/8/8.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.10.0/requirements.txt | 2 + .../atlassian/jira/8/8.10.1/Makefile | 23 +++ .../atlassian/jira/8/8.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.10.1/requirements.txt | 2 + .../atlassian/jira/8/8.11.0/Makefile | 23 +++ .../atlassian/jira/8/8.11.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.11.0/requirements.txt | 2 + .../atlassian/jira/8/8.11.1/Makefile | 23 +++ .../atlassian/jira/8/8.11.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.11.1/requirements.txt | 2 + .../atlassian/jira/8/8.12.0/Makefile | 23 +++ .../atlassian/jira/8/8.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.12.0/requirements.txt | 2 + .../atlassian/jira/8/8.12.1/Makefile | 23 +++ .../atlassian/jira/8/8.12.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.12.1/requirements.txt | 2 + .../atlassian/jira/8/8.12.2/Makefile | 23 +++ .../atlassian/jira/8/8.12.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.12.2/requirements.txt | 2 + .../atlassian/jira/8/8.12.3/Makefile | 23 +++ .../atlassian/jira/8/8.12.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.12.3/requirements.txt | 2 + .../atlassian/jira/8/8.13.0/Makefile | 23 +++ .../atlassian/jira/8/8.13.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.0/requirements.txt | 2 + .../atlassian/jira/8/8.13.1/Makefile | 23 +++ .../atlassian/jira/8/8.13.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.1/requirements.txt | 2 + .../atlassian/jira/8/8.13.10/Makefile | 23 +++ .../atlassian/jira/8/8.13.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.10/requirements.txt | 2 + .../atlassian/jira/8/8.13.11/Makefile | 23 +++ .../atlassian/jira/8/8.13.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.11/requirements.txt | 2 + .../atlassian/jira/8/8.13.12/Makefile | 23 +++ .../atlassian/jira/8/8.13.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.12/requirements.txt | 2 + .../atlassian/jira/8/8.13.13/Makefile | 23 +++ .../atlassian/jira/8/8.13.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.13/requirements.txt | 2 + .../atlassian/jira/8/8.13.14/Makefile | 23 +++ .../atlassian/jira/8/8.13.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.14/requirements.txt | 2 + .../atlassian/jira/8/8.13.15/Makefile | 23 +++ .../atlassian/jira/8/8.13.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.15/requirements.txt | 2 + .../atlassian/jira/8/8.13.16/Makefile | 23 +++ .../atlassian/jira/8/8.13.16/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.16/requirements.txt | 2 + .../atlassian/jira/8/8.13.17/Makefile | 23 +++ .../atlassian/jira/8/8.13.17/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.17/requirements.txt | 2 + .../atlassian/jira/8/8.13.18/Makefile | 23 +++ .../atlassian/jira/8/8.13.18/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.18/requirements.txt | 2 + .../atlassian/jira/8/8.13.19/Makefile | 23 +++ .../atlassian/jira/8/8.13.19/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.19/requirements.txt | 2 + .../atlassian/jira/8/8.13.2/Makefile | 23 +++ .../atlassian/jira/8/8.13.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.2/requirements.txt | 2 + .../atlassian/jira/8/8.13.20/Makefile | 23 +++ .../atlassian/jira/8/8.13.20/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.20/requirements.txt | 2 + .../atlassian/jira/8/8.13.21/Makefile | 23 +++ .../atlassian/jira/8/8.13.21/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.21/requirements.txt | 2 + .../atlassian/jira/8/8.13.22/Makefile | 23 +++ .../atlassian/jira/8/8.13.22/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.22/requirements.txt | 2 + .../atlassian/jira/8/8.13.24/Makefile | 23 +++ .../atlassian/jira/8/8.13.24/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.24/requirements.txt | 2 + .../atlassian/jira/8/8.13.25/Makefile | 23 +++ .../atlassian/jira/8/8.13.25/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.25/requirements.txt | 2 + .../atlassian/jira/8/8.13.26/Makefile | 23 +++ .../atlassian/jira/8/8.13.26/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.26/requirements.txt | 2 + .../atlassian/jira/8/8.13.27/Makefile | 23 +++ .../atlassian/jira/8/8.13.27/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.27/requirements.txt | 2 + .../atlassian/jira/8/8.13.3/Makefile | 23 +++ .../atlassian/jira/8/8.13.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.3/requirements.txt | 2 + .../atlassian/jira/8/8.13.4/Makefile | 23 +++ .../atlassian/jira/8/8.13.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.4/requirements.txt | 2 + .../atlassian/jira/8/8.13.5/Makefile | 23 +++ .../atlassian/jira/8/8.13.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.5/requirements.txt | 2 + .../atlassian/jira/8/8.13.6/Makefile | 23 +++ .../atlassian/jira/8/8.13.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.6/requirements.txt | 2 + .../atlassian/jira/8/8.13.7/Makefile | 23 +++ .../atlassian/jira/8/8.13.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.7/requirements.txt | 2 + .../atlassian/jira/8/8.13.8/Makefile | 23 +++ .../atlassian/jira/8/8.13.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.8/requirements.txt | 2 + .../atlassian/jira/8/8.13.9/Makefile | 23 +++ .../atlassian/jira/8/8.13.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.13.9/requirements.txt | 2 + .../atlassian/jira/8/8.14.0/Makefile | 23 +++ .../atlassian/jira/8/8.14.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.14.0/requirements.txt | 2 + .../atlassian/jira/8/8.14.1/Makefile | 23 +++ .../atlassian/jira/8/8.14.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.14.1/requirements.txt | 2 + .../atlassian/jira/8/8.15.0/Makefile | 23 +++ .../atlassian/jira/8/8.15.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.15.0/requirements.txt | 2 + .../atlassian/jira/8/8.15.1/Makefile | 23 +++ .../atlassian/jira/8/8.15.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.15.1/requirements.txt | 2 + .../atlassian/jira/8/8.16.0/Makefile | 23 +++ .../atlassian/jira/8/8.16.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.16.0/requirements.txt | 2 + .../atlassian/jira/8/8.16.1/Makefile | 23 +++ .../atlassian/jira/8/8.16.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.16.1/requirements.txt | 2 + .../atlassian/jira/8/8.16.2/Makefile | 23 +++ .../atlassian/jira/8/8.16.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.16.2/requirements.txt | 2 + .../atlassian/jira/8/8.17.0/Makefile | 23 +++ .../atlassian/jira/8/8.17.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.17.0/requirements.txt | 2 + .../atlassian/jira/8/8.17.1/Makefile | 23 +++ .../atlassian/jira/8/8.17.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.17.1/requirements.txt | 2 + .../atlassian/jira/8/8.18.1/Makefile | 23 +++ .../atlassian/jira/8/8.18.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.18.1/requirements.txt | 2 + .../atlassian/jira/8/8.18.2/Makefile | 23 +++ .../atlassian/jira/8/8.18.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.18.2/requirements.txt | 2 + .../atlassian/jira/8/8.19.0/Makefile | 23 +++ .../atlassian/jira/8/8.19.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.19.0/requirements.txt | 2 + .../atlassian/jira/8/8.19.1/Makefile | 23 +++ .../atlassian/jira/8/8.19.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.19.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.0/Makefile | 23 +++ .../atlassian/jira/8/8.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.1/Makefile | 23 +++ .../atlassian/jira/8/8.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.2/Makefile | 23 +++ .../atlassian/jira/8/8.2.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.3/Makefile | 23 +++ .../atlassian/jira/8/8.2.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.4/Makefile | 23 +++ .../atlassian/jira/8/8.2.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.5/Makefile | 23 +++ .../atlassian/jira/8/8.2.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.2.6/Makefile | 23 +++ .../atlassian/jira/8/8.2.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.2.6/requirements.txt | 2 + .../atlassian/jira/8/8.20.0/Makefile | 23 +++ .../atlassian/jira/8/8.20.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.0/requirements.txt | 2 + .../atlassian/jira/8/8.20.1/Makefile | 23 +++ .../atlassian/jira/8/8.20.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.1/requirements.txt | 2 + .../atlassian/jira/8/8.20.10/Makefile | 23 +++ .../atlassian/jira/8/8.20.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.10/requirements.txt | 2 + .../atlassian/jira/8/8.20.11/Makefile | 23 +++ .../atlassian/jira/8/8.20.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.11/requirements.txt | 2 + .../atlassian/jira/8/8.20.12/Makefile | 23 +++ .../atlassian/jira/8/8.20.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.12/requirements.txt | 2 + .../atlassian/jira/8/8.20.13/Makefile | 23 +++ .../atlassian/jira/8/8.20.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.13/requirements.txt | 2 + .../atlassian/jira/8/8.20.14/Makefile | 23 +++ .../atlassian/jira/8/8.20.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.14/requirements.txt | 2 + .../atlassian/jira/8/8.20.15/Makefile | 23 +++ .../atlassian/jira/8/8.20.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.15/requirements.txt | 2 + .../atlassian/jira/8/8.20.16/Makefile | 23 +++ .../atlassian/jira/8/8.20.16/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.16/requirements.txt | 2 + .../atlassian/jira/8/8.20.17/Makefile | 23 +++ .../atlassian/jira/8/8.20.17/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.17/requirements.txt | 2 + .../atlassian/jira/8/8.20.19/Makefile | 23 +++ .../atlassian/jira/8/8.20.19/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.19/requirements.txt | 2 + .../atlassian/jira/8/8.20.2/Makefile | 23 +++ .../atlassian/jira/8/8.20.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.2/requirements.txt | 2 + .../atlassian/jira/8/8.20.20/Makefile | 23 +++ .../atlassian/jira/8/8.20.20/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.20/requirements.txt | 2 + .../atlassian/jira/8/8.20.21/Makefile | 23 +++ .../atlassian/jira/8/8.20.21/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.21/requirements.txt | 2 + .../atlassian/jira/8/8.20.22/Makefile | 23 +++ .../atlassian/jira/8/8.20.22/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.22/requirements.txt | 2 + .../atlassian/jira/8/8.20.23/Makefile | 23 +++ .../atlassian/jira/8/8.20.23/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.23/requirements.txt | 2 + .../atlassian/jira/8/8.20.24/Makefile | 23 +++ .../atlassian/jira/8/8.20.24/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.24/requirements.txt | 2 + .../atlassian/jira/8/8.20.25/Makefile | 23 +++ .../atlassian/jira/8/8.20.25/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.25/requirements.txt | 2 + .../atlassian/jira/8/8.20.26/Makefile | 23 +++ .../atlassian/jira/8/8.20.26/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.26/requirements.txt | 2 + .../atlassian/jira/8/8.20.27/Makefile | 23 +++ .../atlassian/jira/8/8.20.27/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.27/requirements.txt | 2 + .../atlassian/jira/8/8.20.28/Makefile | 23 +++ .../atlassian/jira/8/8.20.28/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.28/requirements.txt | 2 + .../atlassian/jira/8/8.20.29/Makefile | 23 +++ .../atlassian/jira/8/8.20.29/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.29/requirements.txt | 2 + .../atlassian/jira/8/8.20.3/Makefile | 23 +++ .../atlassian/jira/8/8.20.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.3/requirements.txt | 2 + .../atlassian/jira/8/8.20.30/Makefile | 23 +++ .../atlassian/jira/8/8.20.30/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.30/requirements.txt | 2 + .../atlassian/jira/8/8.20.4/Makefile | 23 +++ .../atlassian/jira/8/8.20.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.4/requirements.txt | 2 + .../atlassian/jira/8/8.20.5/Makefile | 23 +++ .../atlassian/jira/8/8.20.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.5/requirements.txt | 2 + .../atlassian/jira/8/8.20.6/Makefile | 23 +++ .../atlassian/jira/8/8.20.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.6/requirements.txt | 2 + .../atlassian/jira/8/8.20.7/Makefile | 23 +++ .../atlassian/jira/8/8.20.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.7/requirements.txt | 2 + .../atlassian/jira/8/8.20.8/Makefile | 23 +++ .../atlassian/jira/8/8.20.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.8/requirements.txt | 2 + .../atlassian/jira/8/8.20.9/Makefile | 23 +++ .../atlassian/jira/8/8.20.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.20.9/requirements.txt | 2 + .../atlassian/jira/8/8.21.0/Makefile | 23 +++ .../atlassian/jira/8/8.21.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.21.0/requirements.txt | 2 + .../atlassian/jira/8/8.21.1/Makefile | 23 +++ .../atlassian/jira/8/8.21.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.21.1/requirements.txt | 2 + .../atlassian/jira/8/8.22.0/Makefile | 23 +++ .../atlassian/jira/8/8.22.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.0/requirements.txt | 2 + .../atlassian/jira/8/8.22.1/Makefile | 23 +++ .../atlassian/jira/8/8.22.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.1/requirements.txt | 2 + .../atlassian/jira/8/8.22.2/Makefile | 23 +++ .../atlassian/jira/8/8.22.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.2/requirements.txt | 2 + .../atlassian/jira/8/8.22.3/Makefile | 23 +++ .../atlassian/jira/8/8.22.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.3/requirements.txt | 2 + .../atlassian/jira/8/8.22.4/Makefile | 23 +++ .../atlassian/jira/8/8.22.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.4/requirements.txt | 2 + .../atlassian/jira/8/8.22.5/Makefile | 23 +++ .../atlassian/jira/8/8.22.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.5/requirements.txt | 2 + .../atlassian/jira/8/8.22.6/Makefile | 23 +++ .../atlassian/jira/8/8.22.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.22.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.3.0/Makefile | 23 +++ .../atlassian/jira/8/8.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.3.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.3.1/Makefile | 23 +++ .../atlassian/jira/8/8.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.3.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.3.2/Makefile | 23 +++ .../atlassian/jira/8/8.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.3.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.3.3/Makefile | 23 +++ .../atlassian/jira/8/8.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.3.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.3.4/Makefile | 23 +++ .../atlassian/jira/8/8.3.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.3.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.3.5/Makefile | 23 +++ .../atlassian/jira/8/8.3.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.3.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.4.0/Makefile | 23 +++ .../atlassian/jira/8/8.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.4.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.4.1/Makefile | 23 +++ .../atlassian/jira/8/8.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.4.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.4.2/Makefile | 23 +++ .../atlassian/jira/8/8.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.4.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.4.3/Makefile | 23 +++ .../atlassian/jira/8/8.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.4.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.0/Makefile | 23 +++ .../atlassian/jira/8/8.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.1/Makefile | 23 +++ .../atlassian/jira/8/8.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.1/requirements.txt | 2 + .../atlassian/jira/8/8.5.10/Makefile | 23 +++ .../atlassian/jira/8/8.5.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.10/requirements.txt | 2 + .../atlassian/jira/8/8.5.11/Makefile | 23 +++ .../atlassian/jira/8/8.5.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.11/requirements.txt | 2 + .../atlassian/jira/8/8.5.12/Makefile | 23 +++ .../atlassian/jira/8/8.5.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.12/requirements.txt | 2 + .../atlassian/jira/8/8.5.13/Makefile | 23 +++ .../atlassian/jira/8/8.5.13/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.13/requirements.txt | 2 + .../atlassian/jira/8/8.5.14/Makefile | 23 +++ .../atlassian/jira/8/8.5.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.14/requirements.txt | 2 + .../atlassian/jira/8/8.5.15/Makefile | 23 +++ .../atlassian/jira/8/8.5.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.15/requirements.txt | 2 + .../atlassian/jira/8/8.5.16/Makefile | 23 +++ .../atlassian/jira/8/8.5.16/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.16/requirements.txt | 2 + .../atlassian/jira/8/8.5.17/Makefile | 23 +++ .../atlassian/jira/8/8.5.17/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.17/requirements.txt | 2 + .../atlassian/jira/8/8.5.18/Makefile | 23 +++ .../atlassian/jira/8/8.5.18/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.18/requirements.txt | 2 + .../atlassian/jira/8/8.5.19/Makefile | 23 +++ .../atlassian/jira/8/8.5.19/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.19/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.2/Makefile | 23 +++ .../atlassian/jira/8/8.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.3/Makefile | 23 +++ .../atlassian/jira/8/8.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.4/Makefile | 23 +++ .../atlassian/jira/8/8.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.5/Makefile | 23 +++ .../atlassian/jira/8/8.5.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.6/Makefile | 23 +++ .../atlassian/jira/8/8.5.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.7/Makefile | 23 +++ .../atlassian/jira/8/8.5.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.8/Makefile | 23 +++ .../atlassian/jira/8/8.5.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.5.9/Makefile | 23 +++ .../atlassian/jira/8/8.5.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.5.9/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.6.0/Makefile | 23 +++ .../atlassian/jira/8/8.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.6.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.6.1/Makefile | 23 +++ .../atlassian/jira/8/8.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.6.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.7.0/Makefile | 23 +++ .../atlassian/jira/8/8.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.7.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.7.1/Makefile | 23 +++ .../atlassian/jira/8/8.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.7.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.8.0/Makefile | 23 +++ .../atlassian/jira/8/8.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.8.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.8.1/Makefile | 23 +++ .../atlassian/jira/8/8.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.8.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.9.0/Makefile | 23 +++ .../atlassian/jira/8/8.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.9.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/8/8.9.1/Makefile | 23 +++ .../atlassian/jira/8/8.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/8/8.9.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.0.0/Makefile | 23 +++ .../atlassian/jira/9/9.0.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.0.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.1.0/Makefile | 23 +++ .../atlassian/jira/9/9.1.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.1.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.1.1/Makefile | 23 +++ .../atlassian/jira/9/9.1.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.1.1/requirements.txt | 2 + .../atlassian/jira/9/9.10.0/Makefile | 23 +++ .../atlassian/jira/9/9.10.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.10.0/requirements.txt | 2 + .../atlassian/jira/9/9.10.1/Makefile | 23 +++ .../atlassian/jira/9/9.10.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.10.1/requirements.txt | 2 + .../atlassian/jira/9/9.10.2/Makefile | 23 +++ .../atlassian/jira/9/9.10.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.10.2/requirements.txt | 2 + .../atlassian/jira/9/9.11.0/Makefile | 23 +++ .../atlassian/jira/9/9.11.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.11.0/requirements.txt | 2 + .../atlassian/jira/9/9.11.1/Makefile | 23 +++ .../atlassian/jira/9/9.11.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.11.1/requirements.txt | 2 + .../atlassian/jira/9/9.11.2/Makefile | 23 +++ .../atlassian/jira/9/9.11.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.11.2/requirements.txt | 2 + .../atlassian/jira/9/9.11.3/Makefile | 23 +++ .../atlassian/jira/9/9.11.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.11.3/requirements.txt | 2 + .../atlassian/jira/9/9.12.0/Makefile | 23 +++ .../atlassian/jira/9/9.12.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.12.0/requirements.txt | 2 + .../atlassian/jira/9/9.12.1/Makefile | 23 +++ .../atlassian/jira/9/9.12.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.12.1/requirements.txt | 2 + .../atlassian/jira/9/9.12.2/Makefile | 23 +++ .../atlassian/jira/9/9.12.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.12.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.2.0/Makefile | 23 +++ .../atlassian/jira/9/9.2.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.2.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.2.1/Makefile | 23 +++ .../atlassian/jira/9/9.2.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.2.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.3.0/Makefile | 23 +++ .../atlassian/jira/9/9.3.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.3.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.3.1/Makefile | 23 +++ .../atlassian/jira/9/9.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.3.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.3.2/Makefile | 23 +++ .../atlassian/jira/9/9.3.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.3.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.3.3/Makefile | 23 +++ .../atlassian/jira/9/9.3.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.3.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.0/Makefile | 23 +++ .../atlassian/jira/9/9.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.1/Makefile | 23 +++ .../atlassian/jira/9/9.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.1/requirements.txt | 2 + .../atlassian/jira/9/9.4.10/Makefile | 23 +++ .../atlassian/jira/9/9.4.10/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.10/requirements.txt | 2 + .../atlassian/jira/9/9.4.11/Makefile | 23 +++ .../atlassian/jira/9/9.4.11/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.11/requirements.txt | 2 + .../atlassian/jira/9/9.4.12/Makefile | 23 +++ .../atlassian/jira/9/9.4.12/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.12/requirements.txt | 2 + .../atlassian/jira/9/9.4.14/Makefile | 23 +++ .../atlassian/jira/9/9.4.14/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.14/requirements.txt | 2 + .../atlassian/jira/9/9.4.15/Makefile | 23 +++ .../atlassian/jira/9/9.4.15/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.15/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.2/Makefile | 23 +++ .../atlassian/jira/9/9.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.3/Makefile | 23 +++ .../atlassian/jira/9/9.4.3/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.3/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.4/Makefile | 23 +++ .../atlassian/jira/9/9.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.4/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.5/Makefile | 23 +++ .../atlassian/jira/9/9.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.5/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.6/Makefile | 23 +++ .../atlassian/jira/9/9.4.6/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.6/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.7/Makefile | 23 +++ .../atlassian/jira/9/9.4.7/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.7/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.8/Makefile | 23 +++ .../atlassian/jira/9/9.4.8/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.8/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.4.9/Makefile | 23 +++ .../atlassian/jira/9/9.4.9/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.4.9/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.5.0/Makefile | 23 +++ .../atlassian/jira/9/9.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.5.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.5.1/Makefile | 23 +++ .../atlassian/jira/9/9.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.5.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.6.0/Makefile | 23 +++ .../atlassian/jira/9/9.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.6.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.7.0/Makefile | 23 +++ .../atlassian/jira/9/9.7.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.7.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.7.1/Makefile | 23 +++ .../atlassian/jira/9/9.7.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.7.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.7.2/Makefile | 23 +++ .../atlassian/jira/9/9.7.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.7.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.8.0/Makefile | 23 +++ .../atlassian/jira/9/9.8.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.8.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.8.1/Makefile | 23 +++ .../atlassian/jira/9/9.8.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.8.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.8.2/Makefile | 23 +++ .../atlassian/jira/9/9.8.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.8.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.9.0/Makefile | 23 +++ .../atlassian/jira/9/9.9.0/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.9.0/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.9.1/Makefile | 23 +++ .../atlassian/jira/9/9.9.1/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.9.1/requirements.txt | 2 + .../ecosystem/atlassian/jira/9/9.9.2/Makefile | 23 +++ .../atlassian/jira/9/9.9.2/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/9/9.9.2/requirements.txt | 2 + .../ecosystem/atlassian/jira/latest/Makefile | 23 +++ .../atlassian/jira/latest/kaniko-build.py | 194 ++++++++++++++++++ .../atlassian/jira/latest/requirements.txt | 2 + linux/ecosystem/cassandra/3.11/Makefile | 23 +++ .../ecosystem/cassandra/3.11/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/cassandra/3.11/requirements.txt | 2 + .../electron-release-server/Makefile | 23 +++ .../electron-release-server/kaniko-build.py | 194 ++++++++++++++++++ .../electron-release-server/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/develop/Makefile | 23 +++ .../astra/1.7-alse/develop/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/develop/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk11/Makefile | 23 +++ .../astra/1.7-alse/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk11/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk16/Makefile | 23 +++ .../astra/1.7-alse/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk16/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk17/Makefile | 23 +++ .../astra/1.7-alse/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk17/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk18/Makefile | 23 +++ .../astra/1.7-alse/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk18/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk19/Makefile | 23 +++ .../astra/1.7-alse/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk19/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk20/Makefile | 23 +++ .../astra/1.7-alse/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk20/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk21/Makefile | 23 +++ .../astra/1.7-alse/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk21/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk22/Makefile | 23 +++ .../astra/1.7-alse/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk22/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk6/Makefile | 23 +++ .../astra/1.7-alse/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk6/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk7/Makefile | 23 +++ .../astra/1.7-alse/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk7/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/jdk8/Makefile | 23 +++ .../astra/1.7-alse/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/jdk8/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/main/Makefile | 23 +++ .../astra/1.7-alse/main/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/main/requirements.txt | 2 + .../astra/1.7-alse/python3.10/Makefile | 23 +++ .../astra/1.7-alse/python3.10/kaniko-build.py | 194 ++++++++++++++++++ .../1.7-alse/python3.10/requirements.txt | 2 + .../astra/1.7-alse/python3.11/Makefile | 23 +++ .../astra/1.7-alse/python3.11/kaniko-build.py | 194 ++++++++++++++++++ .../1.7-alse/python3.11/requirements.txt | 2 + .../astra/1.7-alse/python3.12/Makefile | 23 +++ .../astra/1.7-alse/python3.12/kaniko-build.py | 194 ++++++++++++++++++ .../1.7-alse/python3.12/requirements.txt | 2 + .../astra/1.7-alse/python3.13/Makefile | 23 +++ .../astra/1.7-alse/python3.13/kaniko-build.py | 194 ++++++++++++++++++ .../1.7-alse/python3.13/requirements.txt | 2 + .../epicmorg/astra/1.7-alse/slim/Makefile | 23 +++ .../astra/1.7-alse/slim/kaniko-build.py | 194 ++++++++++++++++++ .../astra/1.7-alse/slim/requirements.txt | 2 + .../debian/06-squeeze/develop/Makefile | 23 +++ .../debian/06-squeeze/develop/kaniko-build.py | 194 ++++++++++++++++++ .../06-squeeze/develop/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk11/Makefile | 23 +++ .../debian/06-squeeze/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk11/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk16/Makefile | 23 +++ .../debian/06-squeeze/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk16/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk17/Makefile | 23 +++ .../debian/06-squeeze/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk17/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk18/Makefile | 23 +++ .../debian/06-squeeze/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk18/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk19/Makefile | 23 +++ .../debian/06-squeeze/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk19/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk20/Makefile | 23 +++ .../debian/06-squeeze/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk20/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk21/Makefile | 23 +++ .../debian/06-squeeze/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk21/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk22/Makefile | 23 +++ .../debian/06-squeeze/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk22/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk6/Makefile | 23 +++ .../debian/06-squeeze/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk6/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk7/Makefile | 23 +++ .../debian/06-squeeze/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk7/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/jdk8/Makefile | 23 +++ .../debian/06-squeeze/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/jdk8/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/main/Makefile | 23 +++ .../debian/06-squeeze/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/main/requirements.txt | 2 + .../epicmorg/debian/06-squeeze/slim/Makefile | 23 +++ .../debian/06-squeeze/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/06-squeeze/slim/requirements.txt | 2 + .../debian/07-wheezy/develop/Makefile | 23 +++ .../debian/07-wheezy/develop/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/develop/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk11/Makefile | 23 +++ .../debian/07-wheezy/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk11/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk16/Makefile | 23 +++ .../debian/07-wheezy/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk16/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk17/Makefile | 23 +++ .../debian/07-wheezy/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk17/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk18/Makefile | 23 +++ .../debian/07-wheezy/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk18/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk19/Makefile | 23 +++ .../debian/07-wheezy/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk19/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk20/Makefile | 23 +++ .../debian/07-wheezy/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk20/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk21/Makefile | 23 +++ .../debian/07-wheezy/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk21/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk22/Makefile | 23 +++ .../debian/07-wheezy/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk22/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk6/Makefile | 23 +++ .../debian/07-wheezy/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk6/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk7/Makefile | 23 +++ .../debian/07-wheezy/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk7/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/jdk8/Makefile | 23 +++ .../debian/07-wheezy/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/jdk8/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/main/Makefile | 23 +++ .../debian/07-wheezy/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/main/requirements.txt | 2 + .../epicmorg/debian/07-wheezy/slim/Makefile | 23 +++ .../debian/07-wheezy/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/07-wheezy/slim/requirements.txt | 2 + .../debian/08-jessie/develop/Makefile | 23 +++ .../debian/08-jessie/develop/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/develop/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk11/Makefile | 23 +++ .../debian/08-jessie/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk11/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk16/Makefile | 23 +++ .../debian/08-jessie/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk16/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk17/Makefile | 23 +++ .../debian/08-jessie/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk17/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk18/Makefile | 23 +++ .../debian/08-jessie/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk18/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk19/Makefile | 23 +++ .../debian/08-jessie/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk19/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk20/Makefile | 23 +++ .../debian/08-jessie/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk20/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk21/Makefile | 23 +++ .../debian/08-jessie/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk21/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk22/Makefile | 23 +++ .../debian/08-jessie/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk22/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk6/Makefile | 23 +++ .../debian/08-jessie/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk6/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk7/Makefile | 23 +++ .../debian/08-jessie/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk7/requirements.txt | 2 + .../epicmorg/debian/08-jessie/jdk8/Makefile | 23 +++ .../debian/08-jessie/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/jdk8/requirements.txt | 2 + .../epicmorg/debian/08-jessie/main/Makefile | 23 +++ .../debian/08-jessie/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/main/requirements.txt | 2 + .../epicmorg/debian/08-jessie/slim/Makefile | 23 +++ .../debian/08-jessie/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/08-jessie/slim/requirements.txt | 2 + .../debian/09-stretch/develop/Makefile | 23 +++ .../debian/09-stretch/develop/kaniko-build.py | 194 ++++++++++++++++++ .../09-stretch/develop/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk11/Makefile | 23 +++ .../debian/09-stretch/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk11/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk16/Makefile | 23 +++ .../debian/09-stretch/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk16/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk17/Makefile | 23 +++ .../debian/09-stretch/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk17/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk18/Makefile | 23 +++ .../debian/09-stretch/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk18/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk19/Makefile | 23 +++ .../debian/09-stretch/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk19/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk20/Makefile | 23 +++ .../debian/09-stretch/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk20/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk21/Makefile | 23 +++ .../debian/09-stretch/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk21/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk22/Makefile | 23 +++ .../debian/09-stretch/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk22/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk6/Makefile | 23 +++ .../debian/09-stretch/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk6/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk7/Makefile | 23 +++ .../debian/09-stretch/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk7/requirements.txt | 2 + .../epicmorg/debian/09-stretch/jdk8/Makefile | 23 +++ .../debian/09-stretch/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/jdk8/requirements.txt | 2 + .../epicmorg/debian/09-stretch/main/Makefile | 23 +++ .../debian/09-stretch/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/main/requirements.txt | 2 + .../epicmorg/debian/09-stretch/slim/Makefile | 23 +++ .../debian/09-stretch/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/09-stretch/slim/requirements.txt | 2 + .../debian/10-buster/develop/Makefile | 23 +++ .../debian/10-buster/develop/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/develop/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk11/Makefile | 23 +++ .../debian/10-buster/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk11/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk16/Makefile | 23 +++ .../debian/10-buster/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk16/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk17/Makefile | 23 +++ .../debian/10-buster/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk17/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk18/Makefile | 23 +++ .../debian/10-buster/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk18/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk19/Makefile | 23 +++ .../debian/10-buster/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk19/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk20/Makefile | 23 +++ .../debian/10-buster/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk20/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk21/Makefile | 23 +++ .../debian/10-buster/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk21/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk22/Makefile | 23 +++ .../debian/10-buster/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk22/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk6/Makefile | 23 +++ .../debian/10-buster/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk6/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk7/Makefile | 23 +++ .../debian/10-buster/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk7/requirements.txt | 2 + .../epicmorg/debian/10-buster/jdk8/Makefile | 23 +++ .../debian/10-buster/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/jdk8/requirements.txt | 2 + .../epicmorg/debian/10-buster/main/Makefile | 23 +++ .../debian/10-buster/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/main/requirements.txt | 2 + .../epicmorg/debian/10-buster/slim/Makefile | 23 +++ .../debian/10-buster/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/10-buster/slim/requirements.txt | 2 + .../debian/11-bullseye/develop/Makefile | 23 +++ .../11-bullseye/develop/kaniko-build.py | 194 ++++++++++++++++++ .../11-bullseye/develop/requirements.txt | 2 + .../debian/11-bullseye/jdk11/Makefile | 23 +++ .../debian/11-bullseye/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk11/requirements.txt | 2 + .../debian/11-bullseye/jdk16/Makefile | 23 +++ .../debian/11-bullseye/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk16/requirements.txt | 2 + .../debian/11-bullseye/jdk17/Makefile | 23 +++ .../debian/11-bullseye/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk17/requirements.txt | 2 + .../debian/11-bullseye/jdk18/Makefile | 23 +++ .../debian/11-bullseye/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk18/requirements.txt | 2 + .../debian/11-bullseye/jdk19/Makefile | 23 +++ .../debian/11-bullseye/jdk19/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk19/requirements.txt | 2 + .../debian/11-bullseye/jdk20/Makefile | 23 +++ .../debian/11-bullseye/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk20/requirements.txt | 2 + .../debian/11-bullseye/jdk21/Makefile | 23 +++ .../debian/11-bullseye/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk21/requirements.txt | 2 + .../debian/11-bullseye/jdk22/Makefile | 23 +++ .../debian/11-bullseye/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk22/requirements.txt | 2 + .../epicmorg/debian/11-bullseye/jdk6/Makefile | 23 +++ .../debian/11-bullseye/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk6/requirements.txt | 2 + .../epicmorg/debian/11-bullseye/jdk7/Makefile | 23 +++ .../debian/11-bullseye/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk7/requirements.txt | 2 + .../epicmorg/debian/11-bullseye/jdk8/Makefile | 23 +++ .../debian/11-bullseye/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/jdk8/requirements.txt | 2 + .../epicmorg/debian/11-bullseye/main/Makefile | 23 +++ .../debian/11-bullseye/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/main/requirements.txt | 2 + .../epicmorg/debian/11-bullseye/slim/Makefile | 23 +++ .../debian/11-bullseye/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/11-bullseye/slim/requirements.txt | 2 + .../debian/12-bookworm/develop/Makefile | 23 +++ .../12-bookworm/develop/kaniko-build.py | 194 ++++++++++++++++++ .../12-bookworm/develop/requirements.txt | 2 + .../debian/12-bookworm/jdk11/Makefile | 23 +++ .../debian/12-bookworm/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk11/requirements.txt | 2 + .../debian/12-bookworm/jdk16/Makefile | 23 +++ .../debian/12-bookworm/jdk16/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk16/requirements.txt | 2 + .../debian/12-bookworm/jdk17/Makefile | 23 +++ .../debian/12-bookworm/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk17/requirements.txt | 2 + .../debian/12-bookworm/jdk18/Makefile | 23 +++ .../debian/12-bookworm/jdk18/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk18/requirements.txt | 2 + .../debian/12-bookworm/jdk20/Makefile | 23 +++ .../debian/12-bookworm/jdk20/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk20/requirements.txt | 2 + .../debian/12-bookworm/jdk21/Makefile | 23 +++ .../debian/12-bookworm/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk21/requirements.txt | 2 + .../debian/12-bookworm/jdk22/Makefile | 23 +++ .../debian/12-bookworm/jdk22/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk22/requirements.txt | 2 + .../epicmorg/debian/12-bookworm/jdk6/Makefile | 23 +++ .../debian/12-bookworm/jdk6/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk6/requirements.txt | 2 + .../epicmorg/debian/12-bookworm/jdk7/Makefile | 23 +++ .../debian/12-bookworm/jdk7/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk7/requirements.txt | 2 + .../epicmorg/debian/12-bookworm/jdk8/Makefile | 23 +++ .../debian/12-bookworm/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/jdk8/requirements.txt | 2 + .../epicmorg/debian/12-bookworm/main/Makefile | 23 +++ .../debian/12-bookworm/main/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/main/requirements.txt | 2 + .../epicmorg/debian/12-bookworm/slim/Makefile | 23 +++ .../debian/12-bookworm/slim/kaniko-build.py | 194 ++++++++++++++++++ .../debian/12-bookworm/slim/requirements.txt | 2 + .../gitlab/runner/amxx-sdk/1.10/Makefile | 23 +++ .../runner/amxx-sdk/1.10/kaniko-build.py | 194 ++++++++++++++++++ .../runner/amxx-sdk/1.10/requirements.txt | 2 + .../gitlab/runner/amxx-sdk/1.9/Makefile | 23 +++ .../runner/amxx-sdk/1.9/kaniko-build.py | 194 ++++++++++++++++++ .../runner/amxx-sdk/1.9/requirements.txt | 2 + .../gitlab/runner/android-sdk/jdk11/Makefile | 23 +++ .../runner/android-sdk/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../runner/android-sdk/jdk11/requirements.txt | 2 + .../gitlab/runner/android-sdk/jdk17/Makefile | 23 +++ .../runner/android-sdk/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../runner/android-sdk/jdk17/requirements.txt | 2 + .../gitlab/runner/android-sdk/jdk8/Makefile | 23 +++ .../runner/android-sdk/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../runner/android-sdk/jdk8/requirements.txt | 2 + .../gitlab/runner/atlassian-sdk/Makefile | 23 +++ .../runner/atlassian-sdk/kaniko-build.py | 194 ++++++++++++++++++ .../runner/atlassian-sdk/requirements.txt | 2 + .../gitlab/runner/dotnet-sdk/Makefile | 23 +++ .../gitlab/runner/dotnet-sdk/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/dotnet-sdk/requirements.txt | 2 + linux/ecosystem/gitlab/runner/latest/Makefile | 23 +++ .../gitlab/runner/latest/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/latest/requirements.txt | 2 + .../ecosystem/gitlab/runner/node0.12/Makefile | 23 +++ .../gitlab/runner/node0.12/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node0.12/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node10/Makefile | 23 +++ .../gitlab/runner/node10/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node10/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node11/Makefile | 23 +++ .../gitlab/runner/node11/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node11/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node12/Makefile | 23 +++ .../gitlab/runner/node12/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node12/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node13/Makefile | 23 +++ .../gitlab/runner/node13/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node13/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node14/Makefile | 23 +++ .../gitlab/runner/node14/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node14/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node15/Makefile | 23 +++ .../gitlab/runner/node15/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node15/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node16/Makefile | 23 +++ .../gitlab/runner/node16/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node16/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node17/Makefile | 23 +++ .../gitlab/runner/node17/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node17/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node18/Makefile | 23 +++ .../gitlab/runner/node18/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node18/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node19/Makefile | 23 +++ .../gitlab/runner/node19/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node19/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node20/Makefile | 23 +++ .../gitlab/runner/node20/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node20/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node21/Makefile | 23 +++ .../gitlab/runner/node21/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node21/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node22/Makefile | 23 +++ .../gitlab/runner/node22/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node22/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node4/Makefile | 23 +++ .../gitlab/runner/node4/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node4/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node5/Makefile | 23 +++ .../gitlab/runner/node5/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node5/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node6/Makefile | 23 +++ .../gitlab/runner/node6/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node6/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node7/Makefile | 23 +++ .../gitlab/runner/node7/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node7/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node8/Makefile | 23 +++ .../gitlab/runner/node8/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node8/requirements.txt | 2 + linux/ecosystem/gitlab/runner/node9/Makefile | 23 +++ .../gitlab/runner/node9/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/node9/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php7.2/Makefile | 23 +++ .../gitlab/runner/php7.2/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php7.2/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php7.3/Makefile | 23 +++ .../gitlab/runner/php7.3/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php7.3/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php7.4/Makefile | 23 +++ .../gitlab/runner/php7.4/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php7.4/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php8.0/Makefile | 23 +++ .../gitlab/runner/php8.0/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php8.0/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php8.1/Makefile | 23 +++ .../gitlab/runner/php8.1/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php8.1/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php8.2/Makefile | 23 +++ .../gitlab/runner/php8.2/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php8.2/requirements.txt | 2 + linux/ecosystem/gitlab/runner/php8.3/Makefile | 23 +++ .../gitlab/runner/php8.3/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/php8.3/requirements.txt | 2 + .../gitlab/runner/steam-sdk/Makefile | 23 +++ .../gitlab/runner/steam-sdk/kaniko-build.py | 194 ++++++++++++++++++ .../gitlab/runner/steam-sdk/requirements.txt | 2 + linux/ecosystem/monero/monerod/Makefile | 23 +++ .../ecosystem/monero/monerod/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/monero/monerod/requirements.txt | 2 + linux/ecosystem/monero/p2pool/Makefile | 23 +++ linux/ecosystem/monero/p2pool/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/monero/p2pool/requirements.txt | 2 + linux/ecosystem/nginx/1.14.2/main/Makefile | 23 +++ .../nginx/1.14.2/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.14.2/main/requirements.txt | 2 + linux/ecosystem/nginx/1.14.2/php/Makefile | 23 +++ .../nginx/1.14.2/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.14.2/php/requirements.txt | 2 + .../ecosystem/nginx/1.14.2/rtmp-hls/Makefile | 23 +++ .../nginx/1.14.2/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.14.2/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.15.12/main/Makefile | 23 +++ .../nginx/1.15.12/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.15.12/main/requirements.txt | 2 + linux/ecosystem/nginx/1.15.12/php/Makefile | 23 +++ .../nginx/1.15.12/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.15.12/php/requirements.txt | 2 + .../ecosystem/nginx/1.15.12/rtmp-hls/Makefile | 23 +++ .../nginx/1.15.12/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.15.12/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.16.1/main/Makefile | 23 +++ .../nginx/1.16.1/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.16.1/main/requirements.txt | 2 + linux/ecosystem/nginx/1.16.1/php/Makefile | 23 +++ .../nginx/1.16.1/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.16.1/php/requirements.txt | 2 + .../ecosystem/nginx/1.16.1/rtmp-hls/Makefile | 23 +++ .../nginx/1.16.1/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.16.1/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.17.10/main/Makefile | 23 +++ .../nginx/1.17.10/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.17.10/main/requirements.txt | 2 + linux/ecosystem/nginx/1.17.10/php/Makefile | 23 +++ .../nginx/1.17.10/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.17.10/php/requirements.txt | 2 + .../ecosystem/nginx/1.17.10/rtmp-hls/Makefile | 23 +++ .../nginx/1.17.10/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.17.10/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.18.0/main/Makefile | 23 +++ .../nginx/1.18.0/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.18.0/main/requirements.txt | 2 + linux/ecosystem/nginx/1.18.0/php/Makefile | 23 +++ .../nginx/1.18.0/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.18.0/php/requirements.txt | 2 + .../ecosystem/nginx/1.18.0/rtmp-hls/Makefile | 23 +++ .../nginx/1.18.0/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.18.0/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.19.10/main/Makefile | 23 +++ .../nginx/1.19.10/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.19.10/main/requirements.txt | 2 + linux/ecosystem/nginx/1.19.10/php/Makefile | 23 +++ .../nginx/1.19.10/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.19.10/php/requirements.txt | 2 + .../ecosystem/nginx/1.19.10/rtmp-hls/Makefile | 23 +++ .../nginx/1.19.10/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.19.10/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.20.1/main/Makefile | 23 +++ .../nginx/1.20.1/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.20.1/main/requirements.txt | 2 + linux/ecosystem/nginx/1.20.1/php/Makefile | 23 +++ .../nginx/1.20.1/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.20.1/php/requirements.txt | 2 + .../ecosystem/nginx/1.20.1/rtmp-hls/Makefile | 23 +++ .../nginx/1.20.1/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.20.1/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.21.3/main/Makefile | 23 +++ .../nginx/1.21.3/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.21.3/main/requirements.txt | 2 + linux/ecosystem/nginx/1.21.3/php/Makefile | 23 +++ .../nginx/1.21.3/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.21.3/php/requirements.txt | 2 + .../ecosystem/nginx/1.21.3/rtmp-hls/Makefile | 23 +++ .../nginx/1.21.3/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.21.3/rtmp-hls/requirements.txt | 2 + linux/ecosystem/nginx/1.21.6/main/Makefile | 23 +++ .../nginx/1.21.6/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.21.6/main/requirements.txt | 2 + linux/ecosystem/nginx/1.21.6/php/Makefile | 23 +++ .../nginx/1.21.6/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.21.6/php/requirements.txt | 2 + .../ecosystem/nginx/1.21.6/rtmp-hls/Makefile | 23 +++ .../nginx/1.21.6/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/1.21.6/rtmp-hls/requirements.txt | 2 + .../nginx/latest/mainline/main/Makefile | 3 + .../latest/mainline/main/kaniko-build.py | 194 ++++++++++++++++++ .../latest/mainline/main/requirements.txt | 2 + .../nginx/latest/mainline/php/Makefile | 23 +++ .../nginx/latest/mainline/php/kaniko-build.py | 194 ++++++++++++++++++ .../latest/mainline/php/requirements.txt | 2 + .../nginx/latest/mainline/rtmp-hls/Makefile | 23 +++ .../latest/mainline/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../latest/mainline/rtmp-hls/requirements.txt | 2 + .../ecosystem/nginx/latest/quic/main/Makefile | 23 +++ .../nginx/latest/quic/main/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/latest/quic/main/requirements.txt | 2 + .../ecosystem/nginx/latest/quic/php/Makefile | 23 +++ .../nginx/latest/quic/php/kaniko-build.py | 194 ++++++++++++++++++ .../nginx/latest/quic/php/requirements.txt | 2 + .../nginx/latest/quic/rtmp-hls/Makefile | 23 +++ .../latest/quic/rtmp-hls/kaniko-build.py | 194 ++++++++++++++++++ .../latest/quic/rtmp-hls/requirements.txt | 2 + linux/ecosystem/ninjam/latest/Makefile | 23 +++ linux/ecosystem/ninjam/latest/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/ninjam/latest/requirements.txt | 2 + linux/ecosystem/nodejs/current/Makefile | 23 +++ .../ecosystem/nodejs/current/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/current/requirements.txt | 2 + linux/ecosystem/nodejs/lts/Makefile | 23 +++ linux/ecosystem/nodejs/lts/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/lts/requirements.txt | 2 + linux/ecosystem/nodejs/node0.12/Makefile | 23 +++ .../ecosystem/nodejs/node0.12/kaniko-build.py | 194 ++++++++++++++++++ .../nodejs/node0.12/requirements.txt | 2 + linux/ecosystem/nodejs/node10/Makefile | 23 +++ linux/ecosystem/nodejs/node10/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node10/requirements.txt | 2 + linux/ecosystem/nodejs/node11/Makefile | 23 +++ linux/ecosystem/nodejs/node11/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node11/requirements.txt | 2 + linux/ecosystem/nodejs/node12/Makefile | 23 +++ linux/ecosystem/nodejs/node12/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node12/requirements.txt | 2 + linux/ecosystem/nodejs/node13/Makefile | 23 +++ linux/ecosystem/nodejs/node13/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node13/requirements.txt | 2 + linux/ecosystem/nodejs/node14/Makefile | 23 +++ linux/ecosystem/nodejs/node14/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node14/requirements.txt | 2 + linux/ecosystem/nodejs/node15/Makefile | 23 +++ linux/ecosystem/nodejs/node15/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node15/requirements.txt | 2 + linux/ecosystem/nodejs/node16/Makefile | 23 +++ linux/ecosystem/nodejs/node16/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node16/requirements.txt | 2 + linux/ecosystem/nodejs/node17/Makefile | 23 +++ linux/ecosystem/nodejs/node17/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node17/requirements.txt | 2 + linux/ecosystem/nodejs/node18/Makefile | 23 +++ linux/ecosystem/nodejs/node18/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node18/requirements.txt | 2 + linux/ecosystem/nodejs/node19/Makefile | 23 +++ linux/ecosystem/nodejs/node19/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node19/requirements.txt | 2 + linux/ecosystem/nodejs/node20/Makefile | 23 +++ linux/ecosystem/nodejs/node20/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node20/requirements.txt | 2 + linux/ecosystem/nodejs/node21/Makefile | 23 +++ linux/ecosystem/nodejs/node21/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node21/requirements.txt | 2 + linux/ecosystem/nodejs/node22/Makefile | 23 +++ linux/ecosystem/nodejs/node22/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/nodejs/node22/requirements.txt | 2 + linux/ecosystem/nodejs/node4/Makefile | 23 +++ linux/ecosystem/nodejs/node4/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/node4/requirements.txt | 2 + linux/ecosystem/nodejs/node5/Makefile | 23 +++ linux/ecosystem/nodejs/node5/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/node5/requirements.txt | 2 + linux/ecosystem/nodejs/node6/Makefile | 23 +++ linux/ecosystem/nodejs/node6/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/node6/requirements.txt | 2 + linux/ecosystem/nodejs/node7/Makefile | 23 +++ linux/ecosystem/nodejs/node7/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/node7/requirements.txt | 2 + linux/ecosystem/nodejs/node8/Makefile | 23 +++ linux/ecosystem/nodejs/node8/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/node8/requirements.txt | 2 + linux/ecosystem/nodejs/node9/Makefile | 23 +++ linux/ecosystem/nodejs/node9/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/nodejs/node9/requirements.txt | 2 + linux/ecosystem/opentracker/Makefile | 3 + linux/ecosystem/opentracker/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/opentracker/requirements.txt | 2 + linux/ecosystem/perforce/base/r16.2/Makefile | 23 +++ .../perforce/base/r16.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r16.2/requirements.txt | 2 + linux/ecosystem/perforce/base/r17.1/Makefile | 23 +++ .../perforce/base/r17.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r17.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r17.2/Makefile | 23 +++ .../perforce/base/r17.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r17.2/requirements.txt | 2 + linux/ecosystem/perforce/base/r18.1/Makefile | 23 +++ .../perforce/base/r18.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r18.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r18.2/Makefile | 23 +++ .../perforce/base/r18.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r18.2/requirements.txt | 2 + linux/ecosystem/perforce/base/r19.1/Makefile | 23 +++ .../perforce/base/r19.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r19.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r19.2/Makefile | 23 +++ .../perforce/base/r19.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r19.2/requirements.txt | 2 + linux/ecosystem/perforce/base/r20.1/Makefile | 23 +++ .../perforce/base/r20.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r20.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r20.2/Makefile | 23 +++ .../perforce/base/r20.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r20.2/requirements.txt | 2 + linux/ecosystem/perforce/base/r21.1/Makefile | 23 +++ .../perforce/base/r21.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r21.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r21.2/Makefile | 23 +++ .../perforce/base/r21.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r21.2/requirements.txt | 2 + linux/ecosystem/perforce/base/r22.1/Makefile | 23 +++ .../perforce/base/r22.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r22.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r23.1/Makefile | 23 +++ .../perforce/base/r23.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r23.1/requirements.txt | 2 + linux/ecosystem/perforce/base/r23.2/Makefile | 23 +++ .../perforce/base/r23.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/base/r23.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r16.2/Makefile | 23 +++ .../perforce/p4p/r16.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r16.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r17.1/Makefile | 23 +++ .../perforce/p4p/r17.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r17.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r17.2/Makefile | 23 +++ .../perforce/p4p/r17.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r17.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r18.1/Makefile | 23 +++ .../perforce/p4p/r18.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r18.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r18.2/Makefile | 23 +++ .../perforce/p4p/r18.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r18.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r19.1/Makefile | 23 +++ .../perforce/p4p/r19.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r19.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r19.2/Makefile | 23 +++ .../perforce/p4p/r19.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r19.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r20.1/Makefile | 23 +++ .../perforce/p4p/r20.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r20.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r20.2/Makefile | 23 +++ .../perforce/p4p/r20.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r20.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r21.1/Makefile | 23 +++ .../perforce/p4p/r21.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r21.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r21.2/Makefile | 23 +++ .../perforce/p4p/r21.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r21.2/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r22.1/Makefile | 23 +++ .../perforce/p4p/r22.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r22.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r23.1/Makefile | 23 +++ .../perforce/p4p/r23.1/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r23.1/requirements.txt | 2 + linux/ecosystem/perforce/p4p/r23.2/Makefile | 23 +++ .../perforce/p4p/r23.2/kaniko-build.py | 194 ++++++++++++++++++ .../perforce/p4p/r23.2/requirements.txt | 2 + linux/ecosystem/php/php5.5/Makefile | 23 +++ linux/ecosystem/php/php5.5/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php5.5/requirements.txt | 2 + linux/ecosystem/php/php7.0/Makefile | 23 +++ linux/ecosystem/php/php7.0/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php7.0/requirements.txt | 2 + linux/ecosystem/php/php7.1/Makefile | 23 +++ linux/ecosystem/php/php7.1/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php7.1/requirements.txt | 2 + linux/ecosystem/php/php7.2/Makefile | 23 +++ linux/ecosystem/php/php7.2/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php7.2/requirements.txt | 2 + linux/ecosystem/php/php7.3/Makefile | 23 +++ linux/ecosystem/php/php7.3/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php7.3/requirements.txt | 2 + linux/ecosystem/php/php7.4/Makefile | 23 +++ linux/ecosystem/php/php7.4/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php7.4/requirements.txt | 2 + linux/ecosystem/php/php8.0/Makefile | 23 +++ linux/ecosystem/php/php8.0/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php8.0/requirements.txt | 2 + linux/ecosystem/php/php8.1/Makefile | 23 +++ linux/ecosystem/php/php8.1/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php8.1/requirements.txt | 2 + linux/ecosystem/php/php8.2/Makefile | 23 +++ linux/ecosystem/php/php8.2/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php8.2/requirements.txt | 2 + linux/ecosystem/php/php8.3/Makefile | 23 +++ linux/ecosystem/php/php8.3/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/php/php8.3/requirements.txt | 2 + linux/ecosystem/postgres/10/Makefile | 23 +++ linux/ecosystem/postgres/10/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/10/requirements.txt | 2 + linux/ecosystem/postgres/11/Makefile | 23 +++ linux/ecosystem/postgres/11/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/11/requirements.txt | 2 + linux/ecosystem/postgres/12/Makefile | 23 +++ linux/ecosystem/postgres/12/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/12/requirements.txt | 2 + linux/ecosystem/postgres/13/Makefile | 23 +++ linux/ecosystem/postgres/13/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/13/requirements.txt | 2 + linux/ecosystem/postgres/14/Makefile | 23 +++ linux/ecosystem/postgres/14/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/14/requirements.txt | 2 + linux/ecosystem/postgres/15/Makefile | 23 +++ linux/ecosystem/postgres/15/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/15/requirements.txt | 2 + linux/ecosystem/postgres/16/Makefile | 23 +++ linux/ecosystem/postgres/16/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/16/requirements.txt | 2 + linux/ecosystem/postgres/8.2/Makefile | 23 +++ linux/ecosystem/postgres/8.2/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/8.2/requirements.txt | 2 + linux/ecosystem/postgres/8.3/Makefile | 23 +++ linux/ecosystem/postgres/8.3/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/8.3/requirements.txt | 2 + linux/ecosystem/postgres/8.4/Makefile | 23 +++ linux/ecosystem/postgres/8.4/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/8.4/requirements.txt | 2 + linux/ecosystem/postgres/9.0/Makefile | 23 +++ linux/ecosystem/postgres/9.0/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.0/requirements.txt | 2 + linux/ecosystem/postgres/9.1/Makefile | 23 +++ linux/ecosystem/postgres/9.1/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.1/requirements.txt | 2 + linux/ecosystem/postgres/9.2/Makefile | 23 +++ linux/ecosystem/postgres/9.2/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.2/requirements.txt | 2 + linux/ecosystem/postgres/9.3/Makefile | 23 +++ linux/ecosystem/postgres/9.3/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.3/requirements.txt | 2 + linux/ecosystem/postgres/9.4/Makefile | 23 +++ linux/ecosystem/postgres/9.4/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.4/requirements.txt | 2 + linux/ecosystem/postgres/9.5/Makefile | 23 +++ linux/ecosystem/postgres/9.5/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.5/requirements.txt | 2 + linux/ecosystem/postgres/9.6/Makefile | 23 +++ linux/ecosystem/postgres/9.6/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/postgres/9.6/requirements.txt | 2 + linux/ecosystem/postgres/latest/Makefile | 23 +++ .../ecosystem/postgres/latest/kaniko-build.py | 194 ++++++++++++++++++ .../postgres/latest/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.4.0/Makefile | 3 + .../qbittorrent/4.4.0/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.4.0/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.4.1/Makefile | 3 + .../qbittorrent/4.4.1/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.4.1/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.4.2/Makefile | 3 + .../qbittorrent/4.4.2/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.4.2/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.4.3.1/Makefile | 3 + .../qbittorrent/4.4.3.1/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.4.3.1/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.4.4/Makefile | 3 + .../qbittorrent/4.4.4/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.4.4/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.4.5/Makefile | 3 + .../qbittorrent/4.4.5/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.4.5/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.5.0/Makefile | 3 + .../qbittorrent/4.5.0/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.5.0/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.5.1/Makefile | 3 + .../qbittorrent/4.5.1/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.5.1/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.5.2/Makefile | 3 + .../qbittorrent/4.5.2/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.5.2/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.5.3/Makefile | 3 + .../qbittorrent/4.5.3/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.5.3/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.5.4/Makefile | 3 + .../qbittorrent/4.5.4/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.5.4/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.5.5/Makefile | 3 + .../qbittorrent/4.5.5/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.5.5/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.6.0/Makefile | 3 + .../qbittorrent/4.6.0/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.6.0/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.6.1/Makefile | 3 + .../qbittorrent/4.6.1/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.6.1/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.6.2/Makefile | 3 + .../qbittorrent/4.6.2/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.6.2/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.6.3/Makefile | 3 + .../qbittorrent/4.6.3/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.6.3/requirements.txt | 2 + linux/ecosystem/qbittorrent/4.6.4/Makefile | 3 + .../qbittorrent/4.6.4/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/4.6.4/requirements.txt | 2 + linux/ecosystem/qbittorrent/testing/Makefile | 3 + .../qbittorrent/testing/kaniko-build.py | 194 ++++++++++++++++++ .../qbittorrent/testing/requirements.txt | 2 + linux/ecosystem/retracker/Makefile | 23 +++ linux/ecosystem/retracker/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/retracker/requirements.txt | 2 + .../teamcity/agent/amxx-sdk/1.10/Makefile | 23 +++ .../agent/amxx-sdk/1.10/kaniko-build.py | 194 ++++++++++++++++++ .../agent/amxx-sdk/1.10/requirements.txt | 2 + .../teamcity/agent/amxx-sdk/1.9/Makefile | 23 +++ .../agent/amxx-sdk/1.9/kaniko-build.py | 194 ++++++++++++++++++ .../agent/amxx-sdk/1.9/requirements.txt | 2 + .../teamcity/agent/android-sdk/jdk11/Makefile | 23 +++ .../agent/android-sdk/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../agent/android-sdk/jdk11/requirements.txt | 2 + .../teamcity/agent/android-sdk/jdk17/Makefile | 23 +++ .../agent/android-sdk/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../agent/android-sdk/jdk17/requirements.txt | 2 + .../teamcity/agent/android-sdk/jdk8/Makefile | 23 +++ .../agent/android-sdk/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../agent/android-sdk/jdk8/requirements.txt | 2 + .../teamcity/agent/atlassian-sdk/Makefile | 23 +++ .../agent/atlassian-sdk/kaniko-build.py | 194 ++++++++++++++++++ .../agent/atlassian-sdk/requirements.txt | 2 + .../teamcity/agent/dotnet-sdk/Makefile | 23 +++ .../teamcity/agent/dotnet-sdk/kaniko-build.py | 194 ++++++++++++++++++ .../agent/dotnet-sdk/requirements.txt | 2 + .../teamcity/agent/latest/jdk11/Makefile | 23 +++ .../agent/latest/jdk11/kaniko-build.py | 194 ++++++++++++++++++ .../agent/latest/jdk11/requirements.txt | 2 + .../teamcity/agent/latest/jdk17/Makefile | 23 +++ .../agent/latest/jdk17/kaniko-build.py | 194 ++++++++++++++++++ .../agent/latest/jdk17/requirements.txt | 2 + .../teamcity/agent/latest/jdk21/Makefile | 23 +++ .../agent/latest/jdk21/kaniko-build.py | 194 ++++++++++++++++++ .../agent/latest/jdk21/requirements.txt | 2 + .../teamcity/agent/latest/jdk8/Makefile | 23 +++ .../agent/latest/jdk8/kaniko-build.py | 194 ++++++++++++++++++ .../agent/latest/jdk8/requirements.txt | 2 + .../teamcity/agent/node0.12/Makefile | 23 +++ .../teamcity/agent/node0.12/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node0.12/requirements.txt | 2 + .../ecosystem/teamcity/agent/node10/Makefile | 23 +++ .../teamcity/agent/node10/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node10/requirements.txt | 2 + .../ecosystem/teamcity/agent/node11/Makefile | 23 +++ .../teamcity/agent/node11/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node11/requirements.txt | 2 + .../ecosystem/teamcity/agent/node12/Makefile | 23 +++ .../teamcity/agent/node12/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node12/requirements.txt | 2 + .../ecosystem/teamcity/agent/node13/Makefile | 23 +++ .../teamcity/agent/node13/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node13/requirements.txt | 2 + .../ecosystem/teamcity/agent/node14/Makefile | 23 +++ .../teamcity/agent/node14/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node14/requirements.txt | 2 + .../ecosystem/teamcity/agent/node15/Makefile | 23 +++ .../teamcity/agent/node15/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node15/requirements.txt | 2 + .../ecosystem/teamcity/agent/node16/Makefile | 23 +++ .../teamcity/agent/node16/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node16/requirements.txt | 2 + .../ecosystem/teamcity/agent/node17/Makefile | 23 +++ .../teamcity/agent/node17/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node17/requirements.txt | 2 + .../ecosystem/teamcity/agent/node18/Makefile | 23 +++ .../teamcity/agent/node18/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node18/requirements.txt | 2 + .../ecosystem/teamcity/agent/node19/Makefile | 23 +++ .../teamcity/agent/node19/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node19/requirements.txt | 2 + .../ecosystem/teamcity/agent/node20/Makefile | 23 +++ .../teamcity/agent/node20/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node20/requirements.txt | 2 + .../ecosystem/teamcity/agent/node21/Makefile | 23 +++ .../teamcity/agent/node21/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node21/requirements.txt | 2 + .../ecosystem/teamcity/agent/node22/Makefile | 23 +++ .../teamcity/agent/node22/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node22/requirements.txt | 2 + linux/ecosystem/teamcity/agent/node4/Makefile | 23 +++ .../teamcity/agent/node4/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node4/requirements.txt | 2 + linux/ecosystem/teamcity/agent/node5/Makefile | 23 +++ .../teamcity/agent/node5/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node5/requirements.txt | 2 + linux/ecosystem/teamcity/agent/node6/Makefile | 23 +++ .../teamcity/agent/node6/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node6/requirements.txt | 2 + linux/ecosystem/teamcity/agent/node7/Makefile | 23 +++ .../teamcity/agent/node7/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node7/requirements.txt | 2 + linux/ecosystem/teamcity/agent/node8/Makefile | 23 +++ .../teamcity/agent/node8/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node8/requirements.txt | 2 + linux/ecosystem/teamcity/agent/node9/Makefile | 23 +++ .../teamcity/agent/node9/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/node9/requirements.txt | 2 + .../ecosystem/teamcity/agent/php7.2/Makefile | 23 +++ .../teamcity/agent/php7.2/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php7.2/requirements.txt | 2 + .../ecosystem/teamcity/agent/php7.3/Makefile | 23 +++ .../teamcity/agent/php7.3/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php7.3/requirements.txt | 2 + .../ecosystem/teamcity/agent/php7.4/Makefile | 23 +++ .../teamcity/agent/php7.4/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php7.4/requirements.txt | 2 + .../ecosystem/teamcity/agent/php8.0/Makefile | 23 +++ .../teamcity/agent/php8.0/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php8.0/requirements.txt | 2 + .../ecosystem/teamcity/agent/php8.1/Makefile | 23 +++ .../teamcity/agent/php8.1/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php8.1/requirements.txt | 2 + .../ecosystem/teamcity/agent/php8.2/Makefile | 23 +++ .../teamcity/agent/php8.2/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php8.2/requirements.txt | 2 + .../ecosystem/teamcity/agent/php8.3/Makefile | 23 +++ .../teamcity/agent/php8.3/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/php8.3/requirements.txt | 2 + .../teamcity/agent/steam-sdk/Makefile | 23 +++ .../teamcity/agent/steam-sdk/kaniko-build.py | 194 ++++++++++++++++++ .../teamcity/agent/steam-sdk/requirements.txt | 2 + .../ecosystem/testrail/5.4.1.3669/ad/Makefile | 23 +++ .../testrail/5.4.1.3669/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.4.1.3669/ad/requirements.txt | 2 + .../testrail/5.4.1.3669/ldap/Makefile | 23 +++ .../testrail/5.4.1.3669/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.4.1.3669/ldap/requirements.txt | 2 + .../testrail/5.4.1.3669/main/Makefile | 23 +++ .../testrail/5.4.1.3669/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.4.1.3669/main/requirements.txt | 2 + .../ecosystem/testrail/5.5.0.3727/ad/Makefile | 23 +++ .../testrail/5.5.0.3727/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3727/ad/requirements.txt | 2 + .../testrail/5.5.0.3727/ldap/Makefile | 23 +++ .../testrail/5.5.0.3727/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3727/ldap/requirements.txt | 2 + .../testrail/5.5.0.3727/main/Makefile | 23 +++ .../testrail/5.5.0.3727/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3727/main/requirements.txt | 2 + .../ecosystem/testrail/5.5.0.3731/ad/Makefile | 23 +++ .../testrail/5.5.0.3731/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3731/ad/requirements.txt | 2 + .../testrail/5.5.0.3731/ldap/Makefile | 23 +++ .../testrail/5.5.0.3731/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3731/ldap/requirements.txt | 2 + .../testrail/5.5.0.3731/main/Makefile | 23 +++ .../testrail/5.5.0.3731/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3731/main/requirements.txt | 2 + .../ecosystem/testrail/5.5.0.3735/ad/Makefile | 23 +++ .../testrail/5.5.0.3735/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3735/ad/requirements.txt | 2 + .../testrail/5.5.0.3735/ldap/Makefile | 23 +++ .../testrail/5.5.0.3735/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3735/ldap/requirements.txt | 2 + .../testrail/5.5.0.3735/main/Makefile | 23 +++ .../testrail/5.5.0.3735/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.0.3735/main/requirements.txt | 2 + .../ecosystem/testrail/5.5.1.3746/ad/Makefile | 23 +++ .../testrail/5.5.1.3746/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.1.3746/ad/requirements.txt | 2 + .../testrail/5.5.1.3746/ldap/Makefile | 23 +++ .../testrail/5.5.1.3746/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.1.3746/ldap/requirements.txt | 2 + .../testrail/5.5.1.3746/main/Makefile | 23 +++ .../testrail/5.5.1.3746/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.5.1.3746/main/requirements.txt | 2 + .../ecosystem/testrail/5.6.0.3853/ad/Makefile | 23 +++ .../testrail/5.6.0.3853/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3853/ad/requirements.txt | 2 + .../testrail/5.6.0.3853/ldap/Makefile | 23 +++ .../testrail/5.6.0.3853/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3853/ldap/requirements.txt | 2 + .../testrail/5.6.0.3853/main/Makefile | 23 +++ .../testrail/5.6.0.3853/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3853/main/requirements.txt | 2 + .../ecosystem/testrail/5.6.0.3856/ad/Makefile | 23 +++ .../testrail/5.6.0.3856/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3856/ad/requirements.txt | 2 + .../testrail/5.6.0.3856/ldap/Makefile | 23 +++ .../testrail/5.6.0.3856/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3856/ldap/requirements.txt | 2 + .../testrail/5.6.0.3856/main/Makefile | 23 +++ .../testrail/5.6.0.3856/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3856/main/requirements.txt | 2 + .../ecosystem/testrail/5.6.0.3861/ad/Makefile | 23 +++ .../testrail/5.6.0.3861/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3861/ad/requirements.txt | 2 + .../testrail/5.6.0.3861/ldap/Makefile | 23 +++ .../testrail/5.6.0.3861/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3861/ldap/requirements.txt | 2 + .../testrail/5.6.0.3861/main/Makefile | 23 +++ .../testrail/5.6.0.3861/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3861/main/requirements.txt | 2 + .../ecosystem/testrail/5.6.0.3862/ad/Makefile | 23 +++ .../testrail/5.6.0.3862/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3862/ad/requirements.txt | 2 + .../testrail/5.6.0.3862/ldap/Makefile | 23 +++ .../testrail/5.6.0.3862/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3862/ldap/requirements.txt | 2 + .../testrail/5.6.0.3862/main/Makefile | 23 +++ .../testrail/5.6.0.3862/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3862/main/requirements.txt | 2 + .../ecosystem/testrail/5.6.0.3865/ad/Makefile | 23 +++ .../testrail/5.6.0.3865/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3865/ad/requirements.txt | 2 + .../testrail/5.6.0.3865/ldap/Makefile | 23 +++ .../testrail/5.6.0.3865/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3865/ldap/requirements.txt | 2 + .../testrail/5.6.0.3865/main/Makefile | 23 +++ .../testrail/5.6.0.3865/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.6.0.3865/main/requirements.txt | 2 + .../ecosystem/testrail/5.7.0.3938/ad/Makefile | 23 +++ .../testrail/5.7.0.3938/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3938/ad/requirements.txt | 2 + .../testrail/5.7.0.3938/ldap/Makefile | 23 +++ .../testrail/5.7.0.3938/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3938/ldap/requirements.txt | 2 + .../testrail/5.7.0.3938/main/Makefile | 23 +++ .../testrail/5.7.0.3938/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3938/main/requirements.txt | 2 + .../ecosystem/testrail/5.7.0.3942/ad/Makefile | 23 +++ .../testrail/5.7.0.3942/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3942/ad/requirements.txt | 2 + .../testrail/5.7.0.3942/ldap/Makefile | 23 +++ .../testrail/5.7.0.3942/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3942/ldap/requirements.txt | 2 + .../testrail/5.7.0.3942/main/Makefile | 23 +++ .../testrail/5.7.0.3942/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3942/main/requirements.txt | 2 + .../ecosystem/testrail/5.7.0.3951/ad/Makefile | 23 +++ .../testrail/5.7.0.3951/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3951/ad/requirements.txt | 2 + .../testrail/5.7.0.3951/ldap/Makefile | 23 +++ .../testrail/5.7.0.3951/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3951/ldap/requirements.txt | 2 + .../testrail/5.7.0.3951/main/Makefile | 23 +++ .../testrail/5.7.0.3951/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.0.3951/main/requirements.txt | 2 + .../ecosystem/testrail/5.7.1.4026/ad/Makefile | 23 +++ .../testrail/5.7.1.4026/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.1.4026/ad/requirements.txt | 2 + .../testrail/5.7.1.4026/ldap/Makefile | 23 +++ .../testrail/5.7.1.4026/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.1.4026/ldap/requirements.txt | 2 + .../testrail/5.7.1.4026/main/Makefile | 23 +++ .../testrail/5.7.1.4026/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.1.4026/main/requirements.txt | 2 + .../ecosystem/testrail/5.7.1.4028/ad/Makefile | 23 +++ .../testrail/5.7.1.4028/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.1.4028/ad/requirements.txt | 2 + .../testrail/5.7.1.4028/ldap/Makefile | 23 +++ .../testrail/5.7.1.4028/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.1.4028/ldap/requirements.txt | 2 + .../testrail/5.7.1.4028/main/Makefile | 23 +++ .../testrail/5.7.1.4028/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/5.7.1.4028/main/requirements.txt | 2 + .../ecosystem/testrail/6.0.0.4140/ad/Makefile | 23 +++ .../testrail/6.0.0.4140/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.0.0.4140/ad/requirements.txt | 2 + .../testrail/6.0.0.4140/ldap/Makefile | 23 +++ .../testrail/6.0.0.4140/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.0.0.4140/ldap/requirements.txt | 2 + .../testrail/6.0.0.4140/main/Makefile | 23 +++ .../testrail/6.0.0.4140/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.0.0.4140/main/requirements.txt | 2 + .../ecosystem/testrail/6.0.1.4163/ad/Makefile | 23 +++ .../testrail/6.0.1.4163/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.0.1.4163/ad/requirements.txt | 2 + .../testrail/6.0.1.4163/ldap/Makefile | 23 +++ .../testrail/6.0.1.4163/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.0.1.4163/ldap/requirements.txt | 2 + .../testrail/6.0.1.4163/main/Makefile | 23 +++ .../testrail/6.0.1.4163/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.0.1.4163/main/requirements.txt | 2 + .../ecosystem/testrail/6.1.0.4367/ad/Makefile | 23 +++ .../testrail/6.1.0.4367/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.0.4367/ad/requirements.txt | 2 + .../testrail/6.1.0.4367/ldap/Makefile | 23 +++ .../testrail/6.1.0.4367/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.0.4367/ldap/requirements.txt | 2 + .../testrail/6.1.0.4367/main/Makefile | 23 +++ .../testrail/6.1.0.4367/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.0.4367/main/requirements.txt | 2 + .../ecosystem/testrail/6.1.0.4369/ad/Makefile | 23 +++ .../testrail/6.1.0.4369/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.0.4369/ad/requirements.txt | 2 + .../testrail/6.1.0.4369/ldap/Makefile | 23 +++ .../testrail/6.1.0.4369/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.0.4369/ldap/requirements.txt | 2 + .../testrail/6.1.0.4369/main/Makefile | 23 +++ .../testrail/6.1.0.4369/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.0.4369/main/requirements.txt | 2 + .../ecosystem/testrail/6.1.1.1020/ad/Makefile | 23 +++ .../testrail/6.1.1.1020/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.1.1020/ad/requirements.txt | 2 + .../testrail/6.1.1.1020/ldap/Makefile | 23 +++ .../testrail/6.1.1.1020/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.1.1020/ldap/requirements.txt | 2 + .../testrail/6.1.1.1020/main/Makefile | 23 +++ .../testrail/6.1.1.1020/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.1.1020/main/requirements.txt | 2 + .../ecosystem/testrail/6.1.1.1021/ad/Makefile | 23 +++ .../testrail/6.1.1.1021/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.1.1021/ad/requirements.txt | 2 + .../testrail/6.1.1.1021/ldap/Makefile | 23 +++ .../testrail/6.1.1.1021/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.1.1021/ldap/requirements.txt | 2 + .../testrail/6.1.1.1021/main/Makefile | 23 +++ .../testrail/6.1.1.1021/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.1.1.1021/main/requirements.txt | 2 + .../ecosystem/testrail/6.2.0.1085/ad/Makefile | 23 +++ .../testrail/6.2.0.1085/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.0.1085/ad/requirements.txt | 2 + .../testrail/6.2.0.1085/ldap/Makefile | 23 +++ .../testrail/6.2.0.1085/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.0.1085/ldap/requirements.txt | 2 + .../testrail/6.2.0.1085/main/Makefile | 23 +++ .../testrail/6.2.0.1085/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.0.1085/main/requirements.txt | 2 + .../ecosystem/testrail/6.2.1.1003/ad/Makefile | 23 +++ .../testrail/6.2.1.1003/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.1.1003/ad/requirements.txt | 2 + .../testrail/6.2.1.1003/ldap/Makefile | 23 +++ .../testrail/6.2.1.1003/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.1.1003/ldap/requirements.txt | 2 + .../testrail/6.2.1.1003/main/Makefile | 23 +++ .../testrail/6.2.1.1003/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.1.1003/main/requirements.txt | 2 + .../ecosystem/testrail/6.2.1.1005/ad/Makefile | 23 +++ .../testrail/6.2.1.1005/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.1.1005/ad/requirements.txt | 2 + .../testrail/6.2.1.1005/ldap/Makefile | 23 +++ .../testrail/6.2.1.1005/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.1.1005/ldap/requirements.txt | 2 + .../testrail/6.2.1.1005/main/Makefile | 23 +++ .../testrail/6.2.1.1005/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.1.1005/main/requirements.txt | 2 + .../ecosystem/testrail/6.2.2.1107/ad/Makefile | 23 +++ .../testrail/6.2.2.1107/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.2.1107/ad/requirements.txt | 2 + .../testrail/6.2.2.1107/ldap/Makefile | 23 +++ .../testrail/6.2.2.1107/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.2.1107/ldap/requirements.txt | 2 + .../testrail/6.2.2.1107/main/Makefile | 23 +++ .../testrail/6.2.2.1107/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.2.1107/main/requirements.txt | 2 + .../ecosystem/testrail/6.2.3.1114/ad/Makefile | 23 +++ .../testrail/6.2.3.1114/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.3.1114/ad/requirements.txt | 2 + .../testrail/6.2.3.1114/ldap/Makefile | 23 +++ .../testrail/6.2.3.1114/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.3.1114/ldap/requirements.txt | 2 + .../testrail/6.2.3.1114/main/Makefile | 23 +++ .../testrail/6.2.3.1114/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.2.3.1114/main/requirements.txt | 2 + .../ecosystem/testrail/6.3.0.1120/ad/Makefile | 23 +++ .../testrail/6.3.0.1120/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.0.1120/ad/requirements.txt | 2 + .../testrail/6.3.0.1120/ldap/Makefile | 23 +++ .../testrail/6.3.0.1120/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.0.1120/ldap/requirements.txt | 2 + .../testrail/6.3.0.1120/main/Makefile | 23 +++ .../testrail/6.3.0.1120/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.0.1120/main/requirements.txt | 2 + .../ecosystem/testrail/6.3.1.1004/ad/Makefile | 23 +++ .../testrail/6.3.1.1004/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.1.1004/ad/requirements.txt | 2 + .../testrail/6.3.1.1004/ldap/Makefile | 23 +++ .../testrail/6.3.1.1004/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.1.1004/ldap/requirements.txt | 2 + .../testrail/6.3.1.1004/main/Makefile | 23 +++ .../testrail/6.3.1.1004/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.1.1004/main/requirements.txt | 2 + .../ecosystem/testrail/6.3.1.1006/ad/Makefile | 23 +++ .../testrail/6.3.1.1006/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.1.1006/ad/requirements.txt | 2 + .../testrail/6.3.1.1006/ldap/Makefile | 23 +++ .../testrail/6.3.1.1006/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.1.1006/ldap/requirements.txt | 2 + .../testrail/6.3.1.1006/main/Makefile | 23 +++ .../testrail/6.3.1.1006/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.3.1.1006/main/requirements.txt | 2 + .../ecosystem/testrail/6.4.0.1284/ad/Makefile | 23 +++ .../testrail/6.4.0.1284/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.4.0.1284/ad/requirements.txt | 2 + .../testrail/6.4.0.1284/ldap/Makefile | 23 +++ .../testrail/6.4.0.1284/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.4.0.1284/ldap/requirements.txt | 2 + .../testrail/6.4.0.1284/main/Makefile | 23 +++ .../testrail/6.4.0.1284/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.4.0.1284/main/requirements.txt | 2 + .../ecosystem/testrail/6.4.0.1293/ad/Makefile | 23 +++ .../testrail/6.4.0.1293/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.4.0.1293/ad/requirements.txt | 2 + .../testrail/6.4.0.1293/ldap/Makefile | 23 +++ .../testrail/6.4.0.1293/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.4.0.1293/ldap/requirements.txt | 2 + .../testrail/6.4.0.1293/main/Makefile | 23 +++ .../testrail/6.4.0.1293/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.4.0.1293/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.0.1298/ad/Makefile | 23 +++ .../testrail/6.5.0.1298/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.0.1298/ad/requirements.txt | 2 + .../testrail/6.5.0.1298/ldap/Makefile | 23 +++ .../testrail/6.5.0.1298/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.0.1298/ldap/requirements.txt | 2 + .../testrail/6.5.0.1298/main/Makefile | 23 +++ .../testrail/6.5.0.1298/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.0.1298/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.1.1002/ad/Makefile | 23 +++ .../testrail/6.5.1.1002/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.1.1002/ad/requirements.txt | 2 + .../testrail/6.5.1.1002/ldap/Makefile | 23 +++ .../testrail/6.5.1.1002/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.1.1002/ldap/requirements.txt | 2 + .../testrail/6.5.1.1002/main/Makefile | 23 +++ .../testrail/6.5.1.1002/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.1.1002/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.3.1001/ad/Makefile | 23 +++ .../testrail/6.5.3.1001/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.3.1001/ad/requirements.txt | 2 + .../testrail/6.5.3.1001/ldap/Makefile | 23 +++ .../testrail/6.5.3.1001/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.3.1001/ldap/requirements.txt | 2 + .../testrail/6.5.3.1001/main/Makefile | 23 +++ .../testrail/6.5.3.1001/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.3.1001/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.4.1002/ad/Makefile | 23 +++ .../testrail/6.5.4.1002/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.4.1002/ad/requirements.txt | 2 + .../testrail/6.5.4.1002/ldap/Makefile | 23 +++ .../testrail/6.5.4.1002/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.4.1002/ldap/requirements.txt | 2 + .../testrail/6.5.4.1002/main/Makefile | 23 +++ .../testrail/6.5.4.1002/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.4.1002/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.4.1007/ad/Makefile | 23 +++ .../testrail/6.5.4.1007/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.4.1007/ad/requirements.txt | 2 + .../testrail/6.5.4.1007/ldap/Makefile | 23 +++ .../testrail/6.5.4.1007/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.4.1007/ldap/requirements.txt | 2 + .../testrail/6.5.4.1007/main/Makefile | 23 +++ .../testrail/6.5.4.1007/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.4.1007/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.5.1009/ad/Makefile | 23 +++ .../testrail/6.5.5.1009/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.5.1009/ad/requirements.txt | 2 + .../testrail/6.5.5.1009/ldap/Makefile | 23 +++ .../testrail/6.5.5.1009/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.5.1009/ldap/requirements.txt | 2 + .../testrail/6.5.5.1009/main/Makefile | 23 +++ .../testrail/6.5.5.1009/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.5.1009/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.6.1014/ad/Makefile | 23 +++ .../testrail/6.5.6.1014/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.6.1014/ad/requirements.txt | 2 + .../testrail/6.5.6.1014/ldap/Makefile | 23 +++ .../testrail/6.5.6.1014/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.6.1014/ldap/requirements.txt | 2 + .../testrail/6.5.6.1014/main/Makefile | 23 +++ .../testrail/6.5.6.1014/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.6.1014/main/requirements.txt | 2 + .../ecosystem/testrail/6.5.7.1000/ad/Makefile | 23 +++ .../testrail/6.5.7.1000/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.7.1000/ad/requirements.txt | 2 + .../testrail/6.5.7.1000/ldap/Makefile | 23 +++ .../testrail/6.5.7.1000/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.7.1000/ldap/requirements.txt | 2 + .../testrail/6.5.7.1000/main/Makefile | 23 +++ .../testrail/6.5.7.1000/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.5.7.1000/main/requirements.txt | 2 + .../ecosystem/testrail/6.6.0.1156/ad/Makefile | 23 +++ .../testrail/6.6.0.1156/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.6.0.1156/ad/requirements.txt | 2 + .../testrail/6.6.0.1156/ldap/Makefile | 23 +++ .../testrail/6.6.0.1156/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.6.0.1156/ldap/requirements.txt | 2 + .../testrail/6.6.0.1156/main/Makefile | 23 +++ .../testrail/6.6.0.1156/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.6.0.1156/main/requirements.txt | 2 + .../ecosystem/testrail/6.6.1.1166/ad/Makefile | 23 +++ .../testrail/6.6.1.1166/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.6.1.1166/ad/requirements.txt | 2 + .../testrail/6.6.1.1166/ldap/Makefile | 23 +++ .../testrail/6.6.1.1166/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.6.1.1166/ldap/requirements.txt | 2 + .../testrail/6.6.1.1166/main/Makefile | 23 +++ .../testrail/6.6.1.1166/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.6.1.1166/main/requirements.txt | 2 + .../ecosystem/testrail/6.7.1.1020/ad/Makefile | 23 +++ .../testrail/6.7.1.1020/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.1.1020/ad/requirements.txt | 2 + .../testrail/6.7.1.1020/ldap/Makefile | 23 +++ .../testrail/6.7.1.1020/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.1.1020/ldap/requirements.txt | 2 + .../testrail/6.7.1.1020/main/Makefile | 23 +++ .../testrail/6.7.1.1020/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.1.1020/main/requirements.txt | 2 + .../ecosystem/testrail/6.7.2.1037/ad/Makefile | 23 +++ .../testrail/6.7.2.1037/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.2.1037/ad/requirements.txt | 2 + .../testrail/6.7.2.1037/ldap/Makefile | 23 +++ .../testrail/6.7.2.1037/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.2.1037/ldap/requirements.txt | 2 + .../testrail/6.7.2.1037/main/Makefile | 23 +++ .../testrail/6.7.2.1037/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.2.1037/main/requirements.txt | 2 + .../ecosystem/testrail/6.7.2.1043/ad/Makefile | 23 +++ .../testrail/6.7.2.1043/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.2.1043/ad/requirements.txt | 2 + .../testrail/6.7.2.1043/ldap/Makefile | 23 +++ .../testrail/6.7.2.1043/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.2.1043/ldap/requirements.txt | 2 + .../testrail/6.7.2.1043/main/Makefile | 23 +++ .../testrail/6.7.2.1043/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/6.7.2.1043/main/requirements.txt | 2 + .../ecosystem/testrail/7.0.0.1057/ad/Makefile | 23 +++ .../testrail/7.0.0.1057/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.0.1057/ad/requirements.txt | 2 + .../testrail/7.0.0.1057/ldap/Makefile | 23 +++ .../testrail/7.0.0.1057/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.0.1057/ldap/requirements.txt | 2 + .../testrail/7.0.0.1057/main/Makefile | 23 +++ .../testrail/7.0.0.1057/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.0.1057/main/requirements.txt | 2 + .../ecosystem/testrail/7.0.1.1002/ad/Makefile | 23 +++ .../testrail/7.0.1.1002/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.1.1002/ad/requirements.txt | 2 + .../testrail/7.0.1.1002/ldap/Makefile | 23 +++ .../testrail/7.0.1.1002/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.1.1002/ldap/requirements.txt | 2 + .../testrail/7.0.1.1002/main/Makefile | 23 +++ .../testrail/7.0.1.1002/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.1.1002/main/requirements.txt | 2 + .../ecosystem/testrail/7.0.1.1013/ad/Makefile | 23 +++ .../testrail/7.0.1.1013/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.1.1013/ad/requirements.txt | 2 + .../testrail/7.0.1.1013/ldap/Makefile | 23 +++ .../testrail/7.0.1.1013/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.1.1013/ldap/requirements.txt | 2 + .../testrail/7.0.1.1013/main/Makefile | 23 +++ .../testrail/7.0.1.1013/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.1.1013/main/requirements.txt | 2 + .../ecosystem/testrail/7.0.2.1014/ad/Makefile | 23 +++ .../testrail/7.0.2.1014/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1014/ad/requirements.txt | 2 + .../testrail/7.0.2.1014/ldap/Makefile | 23 +++ .../testrail/7.0.2.1014/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1014/ldap/requirements.txt | 2 + .../testrail/7.0.2.1014/main/Makefile | 23 +++ .../testrail/7.0.2.1014/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1014/main/requirements.txt | 2 + .../ecosystem/testrail/7.0.2.1015/ad/Makefile | 23 +++ .../testrail/7.0.2.1015/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1015/ad/requirements.txt | 2 + .../testrail/7.0.2.1015/ldap/Makefile | 23 +++ .../testrail/7.0.2.1015/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1015/ldap/requirements.txt | 2 + .../testrail/7.0.2.1015/main/Makefile | 23 +++ .../testrail/7.0.2.1015/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1015/main/requirements.txt | 2 + .../ecosystem/testrail/7.0.2.1016/ad/Makefile | 23 +++ .../testrail/7.0.2.1016/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1016/ad/requirements.txt | 2 + .../testrail/7.0.2.1016/ldap/Makefile | 23 +++ .../testrail/7.0.2.1016/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1016/ldap/requirements.txt | 2 + .../testrail/7.0.2.1016/main/Makefile | 23 +++ .../testrail/7.0.2.1016/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.0.2.1016/main/requirements.txt | 2 + .../ecosystem/testrail/7.4.1.8079/ad/Makefile | 23 +++ .../testrail/7.4.1.8079/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8079/ad/requirements.txt | 2 + .../testrail/7.4.1.8079/ldap/Makefile | 23 +++ .../testrail/7.4.1.8079/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8079/ldap/requirements.txt | 2 + .../testrail/7.4.1.8079/main/Makefile | 23 +++ .../testrail/7.4.1.8079/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8079/main/requirements.txt | 2 + .../ecosystem/testrail/7.4.1.8091/ad/Makefile | 23 +++ .../testrail/7.4.1.8091/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8091/ad/requirements.txt | 2 + .../testrail/7.4.1.8091/ldap/Makefile | 23 +++ .../testrail/7.4.1.8091/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8091/ldap/requirements.txt | 2 + .../testrail/7.4.1.8091/main/Makefile | 23 +++ .../testrail/7.4.1.8091/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8091/main/requirements.txt | 2 + .../ecosystem/testrail/7.4.1.8092/ad/Makefile | 23 +++ .../testrail/7.4.1.8092/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8092/ad/requirements.txt | 2 + .../testrail/7.4.1.8092/ldap/Makefile | 23 +++ .../testrail/7.4.1.8092/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8092/ldap/requirements.txt | 2 + .../testrail/7.4.1.8092/main/Makefile | 23 +++ .../testrail/7.4.1.8092/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.4.1.8092/main/requirements.txt | 2 + .../ecosystem/testrail/7.5.1.7010/ad/Makefile | 23 +++ .../testrail/7.5.1.7010/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7010/ad/requirements.txt | 2 + .../testrail/7.5.1.7010/ldap/Makefile | 23 +++ .../testrail/7.5.1.7010/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7010/ldap/requirements.txt | 2 + .../testrail/7.5.1.7010/main/Makefile | 23 +++ .../testrail/7.5.1.7010/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7010/main/requirements.txt | 2 + .../ecosystem/testrail/7.5.1.7012/ad/Makefile | 23 +++ .../testrail/7.5.1.7012/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7012/ad/requirements.txt | 2 + .../testrail/7.5.1.7012/ldap/Makefile | 23 +++ .../testrail/7.5.1.7012/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7012/ldap/requirements.txt | 2 + .../testrail/7.5.1.7012/main/Makefile | 23 +++ .../testrail/7.5.1.7012/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7012/main/requirements.txt | 2 + .../ecosystem/testrail/7.5.1.7013/ad/Makefile | 23 +++ .../testrail/7.5.1.7013/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7013/ad/requirements.txt | 2 + .../testrail/7.5.1.7013/ldap/Makefile | 23 +++ .../testrail/7.5.1.7013/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7013/ldap/requirements.txt | 2 + .../testrail/7.5.1.7013/main/Makefile | 23 +++ .../testrail/7.5.1.7013/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.1.7013/main/requirements.txt | 2 + .../ecosystem/testrail/7.5.2.1002/ad/Makefile | 23 +++ .../testrail/7.5.2.1002/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.2.1002/ad/requirements.txt | 2 + .../testrail/7.5.2.1002/ldap/Makefile | 23 +++ .../testrail/7.5.2.1002/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.2.1002/ldap/requirements.txt | 2 + .../testrail/7.5.2.1002/main/Makefile | 23 +++ .../testrail/7.5.2.1002/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.2.1002/main/requirements.txt | 2 + .../ecosystem/testrail/7.5.3.1000/ad/Makefile | 23 +++ .../testrail/7.5.3.1000/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.3.1000/ad/requirements.txt | 2 + .../testrail/7.5.3.1000/ldap/Makefile | 23 +++ .../testrail/7.5.3.1000/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.3.1000/ldap/requirements.txt | 2 + .../testrail/7.5.3.1000/main/Makefile | 23 +++ .../testrail/7.5.3.1000/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/7.5.3.1000/main/requirements.txt | 2 + .../ecosystem/testrail/8.0.0.1089/ad/Makefile | 23 +++ .../testrail/8.0.0.1089/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/8.0.0.1089/ad/requirements.txt | 2 + .../testrail/8.0.0.1089/ldap/Makefile | 23 +++ .../testrail/8.0.0.1089/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/8.0.0.1089/ldap/requirements.txt | 2 + .../testrail/8.0.0.1089/main/Makefile | 23 +++ .../testrail/8.0.0.1089/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/8.0.0.1089/main/requirements.txt | 2 + .../ecosystem/testrail/8.0.1.1029/ad/Makefile | 23 +++ .../testrail/8.0.1.1029/ad/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/8.0.1.1029/ad/requirements.txt | 2 + .../testrail/8.0.1.1029/ldap/Makefile | 23 +++ .../testrail/8.0.1.1029/ldap/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/8.0.1.1029/ldap/requirements.txt | 2 + .../testrail/8.0.1.1029/main/Makefile | 23 +++ .../testrail/8.0.1.1029/main/kaniko-build.py | 194 ++++++++++++++++++ .../testrail/8.0.1.1029/main/requirements.txt | 2 + linux/ecosystem/torrserver/Makefile | 23 +++ linux/ecosystem/torrserver/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/torrserver/requirements.txt | 2 + linux/ecosystem/torrust-index/Makefile | 23 +++ linux/ecosystem/torrust-index/kaniko-build.py | 194 ++++++++++++++++++ .../ecosystem/torrust-index/requirements.txt | 2 + linux/ecosystem/torrust-tracker/Makefile | 23 +++ .../ecosystem/torrust-tracker/kaniko-build.py | 194 ++++++++++++++++++ .../torrust-tracker/requirements.txt | 2 + linux/ecosystem/vk2discord/Makefile | 23 +++ linux/ecosystem/vk2discord/kaniko-build.py | 194 ++++++++++++++++++ linux/ecosystem/vk2discord/requirements.txt | 2 + 4678 files changed, 357975 insertions(+), 3 deletions(-) create mode 100644 bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py create mode 100644 bin/ansible/roles/atlassian.bitbucket/files/requirements.txt create mode 100644 bin/ansible/roles/atlassian.jira/files/kaniko-build.py create mode 100644 bin/ansible/roles/atlassian.jira/files/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php70/ad/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php70/ad/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php70/ldap/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php70/ldap/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php70/main/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php70/main/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php71/ad/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php71/ad/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php71/ldap/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php71/ldap/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php71/main/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php71/main/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php72/ad/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php72/ad/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php72/ldap/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php72/ldap/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php72/main/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php72/main/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php74/ad/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php74/ad/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php74/ldap/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php74/ldap/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php74/main/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php74/main/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php81/ad/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php81/ad/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php81/ldap/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php81/ldap/requirements.txt create mode 100644 bin/ansible/roles/gurock.testrail/files/php81/main/kaniko-build.py create mode 100644 bin/ansible/roles/gurock.testrail/files/php81/main/requirements.txt create mode 100644 bin/kaniko/_deploy.py create mode 100644 bin/kaniko/kaniko-build.py create mode 100644 bin/kaniko/requirements.txt create mode 100644 linux/advanced/mattermost/kaniko-build.py create mode 100644 linux/advanced/mattermost/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/14/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/14/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/15/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/15/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/16/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/16/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/17/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/17/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/18/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/18/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/19/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/19/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/20/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/20/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/21/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/21/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/22/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/22/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/23/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/23/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/24/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/24/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/25/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/25/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/26/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/26/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/27/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/27/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/28/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/28/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/29/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/29/requirements.txt create mode 100644 linux/advanced/nextcloud/patched/latest/kaniko-build.py create mode 100644 linux/advanced/nextcloud/patched/latest/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/14/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/14/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/15/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/15/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/16/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/16/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/17/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/17/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/18/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/18/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/19/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/19/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/20/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/20/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/21/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/21/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/22/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/22/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/23/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/23/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/24/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/24/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/25/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/25/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/26/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/26/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/27/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/27/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/28/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/28/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/29/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/29/requirements.txt create mode 100644 linux/advanced/nextcloud/pure/latest/kaniko-build.py create mode 100644 linux/advanced/nextcloud/pure/latest/requirements.txt create mode 100644 linux/advanced/python/develop/2.7/kaniko-build.py create mode 100644 linux/advanced/python/develop/2.7/requirements.txt create mode 100644 linux/advanced/python/develop/3.10/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.10/requirements.txt create mode 100644 linux/advanced/python/develop/3.11/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.11/requirements.txt create mode 100644 linux/advanced/python/develop/3.12/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.12/requirements.txt create mode 100644 linux/advanced/python/develop/3.13/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.13/requirements.txt create mode 100644 linux/advanced/python/develop/3.6/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.6/requirements.txt create mode 100644 linux/advanced/python/develop/3.7/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.7/requirements.txt create mode 100644 linux/advanced/python/develop/3.8/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.8/requirements.txt create mode 100644 linux/advanced/python/develop/3.9/kaniko-build.py create mode 100644 linux/advanced/python/develop/3.9/requirements.txt create mode 100644 linux/advanced/python/main/2.7/kaniko-build.py create mode 100644 linux/advanced/python/main/2.7/requirements.txt create mode 100644 linux/advanced/python/main/3.10/kaniko-build.py create mode 100644 linux/advanced/python/main/3.10/requirements.txt create mode 100644 linux/advanced/python/main/3.11/kaniko-build.py create mode 100644 linux/advanced/python/main/3.11/requirements.txt create mode 100644 linux/advanced/python/main/3.12/kaniko-build.py create mode 100644 linux/advanced/python/main/3.12/requirements.txt create mode 100644 linux/advanced/python/main/3.13/kaniko-build.py create mode 100644 linux/advanced/python/main/3.13/requirements.txt create mode 100644 linux/advanced/python/main/3.6/kaniko-build.py create mode 100644 linux/advanced/python/main/3.6/requirements.txt create mode 100644 linux/advanced/python/main/3.7/kaniko-build.py create mode 100644 linux/advanced/python/main/3.7/requirements.txt create mode 100644 linux/advanced/python/main/3.8/kaniko-build.py create mode 100644 linux/advanced/python/main/3.8/requirements.txt create mode 100644 linux/advanced/python/main/3.9/kaniko-build.py create mode 100644 linux/advanced/python/main/3.9/requirements.txt create mode 100644 linux/advanced/sentry/latest/kaniko-build.py create mode 100644 linux/advanced/sentry/latest/requirements.txt create mode 100644 linux/advanced/teamcity/server/kaniko-build.py create mode 100644 linux/advanced/teamcity/server/requirements.txt create mode 100644 linux/advanced/vscode-server/amxx/1.10/kaniko-build.py create mode 100644 linux/advanced/vscode-server/amxx/1.10/requirements.txt create mode 100644 linux/advanced/vscode-server/amxx/1.9/kaniko-build.py create mode 100644 linux/advanced/vscode-server/amxx/1.9/requirements.txt create mode 100644 linux/advanced/vscode-server/android/kaniko-build.py create mode 100644 linux/advanced/vscode-server/android/requirements.txt create mode 100644 linux/advanced/vscode-server/cpp/kaniko-build.py create mode 100644 linux/advanced/vscode-server/cpp/requirements.txt create mode 100644 linux/advanced/vscode-server/devops/kaniko-build.py create mode 100644 linux/advanced/vscode-server/devops/requirements.txt create mode 100644 linux/advanced/vscode-server/docker/kaniko-build.py create mode 100644 linux/advanced/vscode-server/docker/requirements.txt create mode 100644 linux/advanced/vscode-server/dotnet-full/kaniko-build.py create mode 100644 linux/advanced/vscode-server/dotnet-full/requirements.txt create mode 100644 linux/advanced/vscode-server/dotnet/kaniko-build.py create mode 100644 linux/advanced/vscode-server/dotnet/requirements.txt create mode 100644 linux/advanced/vscode-server/latest/kaniko-build.py create mode 100644 linux/advanced/vscode-server/latest/requirements.txt create mode 100644 linux/advanced/vscode-server/mono/kaniko-build.py create mode 100644 linux/advanced/vscode-server/mono/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/agent/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/3.0/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/agent/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/4.0/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/agent/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.0/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/agent/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.2/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/agent/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/5.4/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/agent/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.0/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/agent/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.2/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/agent/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/6.4/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/latest/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/agent/requirements.txt create mode 100644 linux/advanced/zabbix/latest/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/latest/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/latest/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/latest/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/latest/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/latest/web-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/agent/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/agent/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/agent2/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/agent2/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/java-gateway/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/server-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/server-pgsql/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/snmptraps/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/web-mysql/requirements.txt create mode 100644 linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py create mode 100644 linux/advanced/zabbix/trunk/web-pgsql/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3.1/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3.2/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt create mode 100644 linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt create mode 100644 linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py create mode 100644 linux/discontinued/ecosystem/syspass/sysPass/requirements.txt create mode 100644 linux/ecosystem/apache2/php5.5/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php5.5/requirements.txt create mode 100644 linux/ecosystem/apache2/php7.0/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php7.0/requirements.txt create mode 100644 linux/ecosystem/apache2/php7.1/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php7.1/requirements.txt create mode 100644 linux/ecosystem/apache2/php7.2/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php7.2/requirements.txt create mode 100644 linux/ecosystem/apache2/php7.3/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php7.3/requirements.txt create mode 100644 linux/ecosystem/apache2/php7.4/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php7.4/requirements.txt create mode 100644 linux/ecosystem/apache2/php8.0/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php8.0/requirements.txt create mode 100644 linux/ecosystem/apache2/php8.1/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php8.1/requirements.txt create mode 100644 linux/ecosystem/apache2/php8.2/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php8.2/requirements.txt create mode 100644 linux/ecosystem/apache2/php8.3/kaniko-build.py create mode 100644 linux/ecosystem/apache2/php8.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.6.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.7.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.8.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.8.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.9.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.11.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.11.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.12.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.13.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.13.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/7/7.21.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.17.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/latest/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.18/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.19/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.20/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.21/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.18/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/latest/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/latest/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/templates/5/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/templates/6/requirements.txt create mode 100644 linux/ecosystem/atlassian/crowd/5/5.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crowd/latest/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crowd/latest/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5.a/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5a/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/crucible/templates/1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.0.1a/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.2.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5.a/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5a/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/4/4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/5/5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/6/6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.0-m01/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.11.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.11.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.11.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.12.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.12.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.18/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/7/7.9.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.0.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.0.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.11.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.11.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.18/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.19/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.20/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.21/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.22/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.24/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.25/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.26/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.27/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.14.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.14.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.15.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.15.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.16.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.16.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.16.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.17.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.17.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.18.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.18.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.19.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.19.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.19/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.20/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.21/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.22/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.23/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.24/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.25/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.26/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.27/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.28/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.29/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.30/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.21.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.21.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.13/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.16/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.17/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.18/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.19/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.6.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/8/8.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.1.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.1.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.10.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.10.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.10.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.2.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.2.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.10/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.11/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.14/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.15/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.3/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.4/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.7/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.8/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.9/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.5.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.5.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.6.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.7.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.7.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.7.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.8.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.8.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.9.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.9.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.9.2/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/latest/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/latest/requirements.txt create mode 100644 linux/ecosystem/cassandra/3.11/kaniko-build.py create mode 100644 linux/ecosystem/cassandra/3.11/requirements.txt create mode 100644 linux/ecosystem/electron-release-server/kaniko-build.py create mode 100644 linux/ecosystem/electron-release-server/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py create mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/amxx-sdk/1.10/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/amxx-sdk/1.9/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/latest/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/latest/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node0.12/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node10/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node10/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node11/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node11/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node12/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node12/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node13/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node13/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node14/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node14/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node15/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node15/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node16/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node16/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node17/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node17/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node18/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node18/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node19/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node19/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node20/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node20/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node21/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node21/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node22/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node22/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node4/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node4/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node5/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node5/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node6/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node6/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node7/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node7/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node8/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node8/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/node9/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/node9/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php7.2/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php7.3/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php7.4/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php8.0/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php8.1/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php8.2/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/php8.3/requirements.txt create mode 100644 linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py create mode 100644 linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt create mode 100644 linux/ecosystem/monero/monerod/kaniko-build.py create mode 100644 linux/ecosystem/monero/monerod/requirements.txt create mode 100644 linux/ecosystem/monero/p2pool/kaniko-build.py create mode 100644 linux/ecosystem/monero/p2pool/requirements.txt create mode 100644 linux/ecosystem/nginx/1.14.2/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.14.2/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.14.2/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.14.2/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.14.2/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.15.12/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.15.12/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.15.12/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.15.12/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.15.12/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.16.1/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.16.1/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.16.1/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.16.1/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.16.1/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.17.10/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.17.10/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.17.10/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.17.10/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.17.10/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.18.0/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.18.0/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.18.0/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.18.0/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.18.0/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.19.10/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.19.10/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.19.10/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.19.10/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.19.10/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.20.1/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.20.1/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.20.1/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.20.1/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.20.1/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.21.3/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.21.3/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.21.3/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.21.3/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.21.3/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/1.21.6/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.21.6/main/requirements.txt create mode 100644 linux/ecosystem/nginx/1.21.6/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.21.6/php/requirements.txt create mode 100644 linux/ecosystem/nginx/1.21.6/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/latest/mainline/main/requirements.txt create mode 100644 linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/latest/mainline/php/requirements.txt create mode 100644 linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/nginx/latest/quic/main/kaniko-build.py create mode 100644 linux/ecosystem/nginx/latest/quic/main/requirements.txt create mode 100644 linux/ecosystem/nginx/latest/quic/php/kaniko-build.py create mode 100644 linux/ecosystem/nginx/latest/quic/php/requirements.txt create mode 100644 linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py create mode 100644 linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt create mode 100644 linux/ecosystem/ninjam/latest/kaniko-build.py create mode 100644 linux/ecosystem/ninjam/latest/requirements.txt create mode 100644 linux/ecosystem/nodejs/current/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/current/requirements.txt create mode 100644 linux/ecosystem/nodejs/lts/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/lts/requirements.txt create mode 100644 linux/ecosystem/nodejs/node0.12/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node0.12/requirements.txt create mode 100644 linux/ecosystem/nodejs/node10/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node10/requirements.txt create mode 100644 linux/ecosystem/nodejs/node11/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node11/requirements.txt create mode 100644 linux/ecosystem/nodejs/node12/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node12/requirements.txt create mode 100644 linux/ecosystem/nodejs/node13/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node13/requirements.txt create mode 100644 linux/ecosystem/nodejs/node14/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node14/requirements.txt create mode 100644 linux/ecosystem/nodejs/node15/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node15/requirements.txt create mode 100644 linux/ecosystem/nodejs/node16/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node16/requirements.txt create mode 100644 linux/ecosystem/nodejs/node17/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node17/requirements.txt create mode 100644 linux/ecosystem/nodejs/node18/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node18/requirements.txt create mode 100644 linux/ecosystem/nodejs/node19/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node19/requirements.txt create mode 100644 linux/ecosystem/nodejs/node20/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node20/requirements.txt create mode 100644 linux/ecosystem/nodejs/node21/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node21/requirements.txt create mode 100644 linux/ecosystem/nodejs/node22/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node22/requirements.txt create mode 100644 linux/ecosystem/nodejs/node4/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node4/requirements.txt create mode 100644 linux/ecosystem/nodejs/node5/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node5/requirements.txt create mode 100644 linux/ecosystem/nodejs/node6/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node6/requirements.txt create mode 100644 linux/ecosystem/nodejs/node7/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node7/requirements.txt create mode 100644 linux/ecosystem/nodejs/node8/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node8/requirements.txt create mode 100644 linux/ecosystem/nodejs/node9/kaniko-build.py create mode 100644 linux/ecosystem/nodejs/node9/requirements.txt create mode 100644 linux/ecosystem/opentracker/kaniko-build.py create mode 100644 linux/ecosystem/opentracker/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r16.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r16.2/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r17.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r17.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r17.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r17.2/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r18.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r18.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r18.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r18.2/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r19.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r19.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r19.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r19.2/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r20.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r20.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r20.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r20.2/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r21.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r21.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r21.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r21.2/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r22.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r22.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r23.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r23.1/requirements.txt create mode 100644 linux/ecosystem/perforce/base/r23.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/base/r23.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r16.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r17.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r17.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r18.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r18.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r19.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r19.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r20.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r20.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r21.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r21.2/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r22.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r23.1/requirements.txt create mode 100644 linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py create mode 100644 linux/ecosystem/perforce/p4p/r23.2/requirements.txt create mode 100644 linux/ecosystem/php/php5.5/kaniko-build.py create mode 100644 linux/ecosystem/php/php5.5/requirements.txt create mode 100644 linux/ecosystem/php/php7.0/kaniko-build.py create mode 100644 linux/ecosystem/php/php7.0/requirements.txt create mode 100644 linux/ecosystem/php/php7.1/kaniko-build.py create mode 100644 linux/ecosystem/php/php7.1/requirements.txt create mode 100644 linux/ecosystem/php/php7.2/kaniko-build.py create mode 100644 linux/ecosystem/php/php7.2/requirements.txt create mode 100644 linux/ecosystem/php/php7.3/kaniko-build.py create mode 100644 linux/ecosystem/php/php7.3/requirements.txt create mode 100644 linux/ecosystem/php/php7.4/kaniko-build.py create mode 100644 linux/ecosystem/php/php7.4/requirements.txt create mode 100644 linux/ecosystem/php/php8.0/kaniko-build.py create mode 100644 linux/ecosystem/php/php8.0/requirements.txt create mode 100644 linux/ecosystem/php/php8.1/kaniko-build.py create mode 100644 linux/ecosystem/php/php8.1/requirements.txt create mode 100644 linux/ecosystem/php/php8.2/kaniko-build.py create mode 100644 linux/ecosystem/php/php8.2/requirements.txt create mode 100644 linux/ecosystem/php/php8.3/kaniko-build.py create mode 100644 linux/ecosystem/php/php8.3/requirements.txt create mode 100644 linux/ecosystem/postgres/10/kaniko-build.py create mode 100644 linux/ecosystem/postgres/10/requirements.txt create mode 100644 linux/ecosystem/postgres/11/kaniko-build.py create mode 100644 linux/ecosystem/postgres/11/requirements.txt create mode 100644 linux/ecosystem/postgres/12/kaniko-build.py create mode 100644 linux/ecosystem/postgres/12/requirements.txt create mode 100644 linux/ecosystem/postgres/13/kaniko-build.py create mode 100644 linux/ecosystem/postgres/13/requirements.txt create mode 100644 linux/ecosystem/postgres/14/kaniko-build.py create mode 100644 linux/ecosystem/postgres/14/requirements.txt create mode 100644 linux/ecosystem/postgres/15/kaniko-build.py create mode 100644 linux/ecosystem/postgres/15/requirements.txt create mode 100644 linux/ecosystem/postgres/16/kaniko-build.py create mode 100644 linux/ecosystem/postgres/16/requirements.txt create mode 100644 linux/ecosystem/postgres/8.2/kaniko-build.py create mode 100644 linux/ecosystem/postgres/8.2/requirements.txt create mode 100644 linux/ecosystem/postgres/8.3/kaniko-build.py create mode 100644 linux/ecosystem/postgres/8.3/requirements.txt create mode 100644 linux/ecosystem/postgres/8.4/kaniko-build.py create mode 100644 linux/ecosystem/postgres/8.4/requirements.txt create mode 100644 linux/ecosystem/postgres/9.0/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.0/requirements.txt create mode 100644 linux/ecosystem/postgres/9.1/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.1/requirements.txt create mode 100644 linux/ecosystem/postgres/9.2/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.2/requirements.txt create mode 100644 linux/ecosystem/postgres/9.3/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.3/requirements.txt create mode 100644 linux/ecosystem/postgres/9.4/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.4/requirements.txt create mode 100644 linux/ecosystem/postgres/9.5/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.5/requirements.txt create mode 100644 linux/ecosystem/postgres/9.6/kaniko-build.py create mode 100644 linux/ecosystem/postgres/9.6/requirements.txt create mode 100644 linux/ecosystem/postgres/latest/kaniko-build.py create mode 100644 linux/ecosystem/postgres/latest/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.4.0/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.4.1/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.4.2/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.4.4/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.4.5/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.5.0/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.5.1/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.5.2/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.5.3/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.5.4/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.5.5/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.6.0/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.6.1/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.6.2/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.6.3/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/4.6.4/requirements.txt create mode 100644 linux/ecosystem/qbittorrent/testing/kaniko-build.py create mode 100644 linux/ecosystem/qbittorrent/testing/requirements.txt create mode 100644 linux/ecosystem/retracker/kaniko-build.py create mode 100644 linux/ecosystem/retracker/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/amxx-sdk/1.10/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/amxx-sdk/1.9/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node0.12/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node10/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node10/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node11/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node11/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node12/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node12/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node13/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node13/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node14/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node14/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node15/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node15/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node16/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node16/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node17/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node17/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node18/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node18/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node19/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node19/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node20/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node20/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node21/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node21/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node22/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node22/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node4/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node4/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node5/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node5/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node6/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node6/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node7/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node7/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node8/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node8/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/node9/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/node9/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php7.2/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php7.3/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php7.4/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php8.0/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php8.1/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php8.2/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/php8.3/requirements.txt create mode 100644 linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py create mode 100644 linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt create mode 100644 linux/ecosystem/testrail/5.4.1.3669/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.4.1.3669/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.4.1.3669/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3727/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3727/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3727/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3731/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3731/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3731/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3735/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3735/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.0.3735/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.1.3746/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.1.3746/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.5.1.3746/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3853/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3853/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3853/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3856/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3856/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3856/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3861/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3861/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3861/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3862/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3862/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3862/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3865/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3865/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.6.0.3865/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3938/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3938/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3938/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3942/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3942/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3942/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3951/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3951/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.0.3951/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.1.4026/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.1.4026/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.1.4026/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.1.4028/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.1.4028/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/5.7.1.4028/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.0.0.4140/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.0.0.4140/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.0.0.4140/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.0.1.4163/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.0.1.4163/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.0.1.4163/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.0.4367/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.0.4367/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.0.4367/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.0.4369/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.0.4369/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.0.4369/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.1.1020/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.1.1020/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.1.1020/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.1.1021/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.1.1021/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.1.1.1021/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.0.1085/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.0.1085/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.0.1085/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.1.1003/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.1.1003/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.1.1003/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.1.1005/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.1.1005/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.1.1005/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.2.1107/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.2.1107/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.2.1107/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.3.1114/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.3.1114/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.2.3.1114/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.0.1120/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.0.1120/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.0.1120/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.1.1004/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.1.1004/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.1.1004/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.1.1006/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.1.1006/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.3.1.1006/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.4.0.1284/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.4.0.1284/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.4.0.1284/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.4.0.1293/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.4.0.1293/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.4.0.1293/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.0.1298/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.0.1298/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.0.1298/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.1.1002/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.1.1002/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.1.1002/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.3.1001/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.3.1001/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.3.1001/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.4.1002/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.4.1002/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.4.1002/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.4.1007/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.4.1007/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.4.1007/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.5.1009/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.5.1009/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.5.1009/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.6.1014/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.6.1014/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.6.1014/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.7.1000/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.7.1000/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.5.7.1000/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.6.0.1156/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.6.0.1156/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.6.0.1156/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.6.1.1166/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.6.1.1166/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.6.1.1166/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.1.1020/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.1.1020/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.1.1020/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.2.1037/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.2.1037/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.2.1037/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.2.1043/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.2.1043/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/6.7.2.1043/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.0.1057/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.0.1057/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.0.1057/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.1.1002/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.1.1002/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.1.1002/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.1.1013/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.1.1013/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.1.1013/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1014/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1014/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1014/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1015/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1015/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1015/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1016/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1016/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.0.2.1016/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8079/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8079/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8079/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8091/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8091/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8091/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8092/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8092/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.4.1.8092/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7010/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7010/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7010/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7012/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7012/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7012/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7013/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7013/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.1.7013/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.2.1002/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.2.1002/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.2.1002/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.3.1000/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.3.1000/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/7.5.3.1000/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt create mode 100644 linux/ecosystem/testrail/8.0.0.1089/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/8.0.0.1089/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/8.0.0.1089/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt create mode 100644 linux/ecosystem/testrail/8.0.1.1029/ad/kaniko-build.py create mode 100644 linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt create mode 100644 linux/ecosystem/testrail/8.0.1.1029/ldap/kaniko-build.py create mode 100644 linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt create mode 100644 linux/ecosystem/testrail/8.0.1.1029/main/kaniko-build.py create mode 100644 linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt create mode 100644 linux/ecosystem/torrserver/kaniko-build.py create mode 100644 linux/ecosystem/torrserver/requirements.txt create mode 100644 linux/ecosystem/torrust-index/kaniko-build.py create mode 100644 linux/ecosystem/torrust-index/requirements.txt create mode 100644 linux/ecosystem/torrust-tracker/kaniko-build.py create mode 100644 linux/ecosystem/torrust-tracker/requirements.txt create mode 100644 linux/ecosystem/vk2discord/kaniko-build.py create mode 100644 linux/ecosystem/vk2discord/requirements.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index d293067dd..8af723e8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## 2024 * `jun` + * added support of `kaniko` build system: + * defaut build scripts now builds with `kaniko` via `make build` and `make deploy`. + * classic build via `docker-compose` was saved as `make build-compose` and `make deploy-compose`. + * added new argument - `dry` or `dry-run`. kind of old `make build`. it only build image locally and cleanup. * impoverd `nodejs 0-22` base images. * deprecated installation via package manager. * installation from archive. diff --git a/Makefile b/Makefile index 1b5f57a1f..b9b189eab 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,8 @@ -VERSION = "2024.06.21" +VERSION = "2024.06.24" AUTHOR = "EpicMorg" MODIFIED = "STAM" DOCKER_SCAN_SUGGEST = false -all: app - app: @make -s version @make -s help @@ -37,6 +35,19 @@ ansible.gen.bitbucket: ansible.gen.testrail: cd `pwd`/bin/ansible && ansible-playbook ./generate.testrail.yml +pip: + 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 && \ + cd bin/kaniko && \ + pip install -r requirements.txt + +kaniko.update: + make pip + cd bin/kaniko && \ + python3 _deploy.py + git: git add . git commit -am "make - autocommit" diff --git a/bin/ansible/roles/atlassian.bitbucket/files/Makefile b/bin/ansible/roles/atlassian.bitbucket/files/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/atlassian.bitbucket/files/Makefile +++ b/bin/ansible/roles/atlassian.bitbucket/files/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py b/bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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.bitbucket/files/requirements.txt b/bin/ansible/roles/atlassian.bitbucket/files/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/atlassian.bitbucket/files/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/atlassian.jira/files/Makefile b/bin/ansible/roles/atlassian.jira/files/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/atlassian.jira/files/Makefile +++ b/bin/ansible/roles/atlassian.jira/files/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/bin/ansible/roles/atlassian.jira/files/kaniko-build.py b/bin/ansible/roles/atlassian.jira/files/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/atlassian.jira/files/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/atlassian.jira/files/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/atlassian.jira/files/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php70/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php70/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php70/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php70/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php70/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php70/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php70/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php70/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php70/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php71/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php71/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php71/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php71/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php71/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php71/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php71/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php71/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php71/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php72/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php72/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php72/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php72/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php72/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php72/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php72/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php72/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php72/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php74/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php74/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php74/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php74/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php74/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php74/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php74/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php74/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php74/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php81/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php81/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php81/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php81/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php81/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php81/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php81/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/ansible/roles/gurock.testrail/files/php81/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/ansible/roles/gurock.testrail/files/php81/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/bin/kaniko/_deploy.py b/bin/kaniko/_deploy.py new file mode 100644 index 000000000..8d874fc0a --- /dev/null +++ b/bin/kaniko/_deploy.py @@ -0,0 +1,42 @@ +import os +import shutil + +def copy_files_to_directories(root_directory, script_directory, ignore_directory, files_to_copy): + for subdir, dirs, files in os.walk(root_directory): + # Ignore the specified directory + if ignore_directory in subdir: + continue + + if 'docker-compose.yml' in files and 'Dockerfile' in files: + for file_name in files_to_copy: + source = os.path.join(script_directory, file_name) + destination = os.path.join(subdir, file_name) + # Copy and overwrite the file if it already exists + shutil.copyfile(source, destination) + print(f"Copied {file_name} to {subdir}") + +def main(): + # Determine the root directory of the project as two levels above the current script + current_directory = os.path.dirname(os.path.abspath(__file__)) + root_directory = os.path.abspath(os.path.join(current_directory, '..', '..')) + + # Directory where the source scripts are located + script_directory = os.path.join(root_directory, 'bin/kaniko') + + # Directory to ignore + ignore_directory = os.path.join(root_directory, 'win32') + + # List of files to copy + files_to_copy = ['kaniko-build.py', 'requirements.txt'] + + # Check if the source files exist in the script directory + for file_name in files_to_copy: + if not os.path.exists(os.path.join(script_directory, file_name)): + print(f"{file_name} not found in {script_directory}.") + return + + # Copy the files to the appropriate directories + copy_files_to_directories(root_directory, script_directory, ignore_directory, files_to_copy) + +if __name__ == '__main__': + main() diff --git a/bin/kaniko/kaniko-build.py b/bin/kaniko/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/bin/kaniko/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/requirements.txt b/bin/kaniko/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/bin/kaniko/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/mattermost/Makefile b/linux/advanced/mattermost/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/mattermost/Makefile +++ b/linux/advanced/mattermost/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/mattermost/kaniko-build.py b/linux/advanced/mattermost/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/mattermost/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/mattermost/requirements.txt b/linux/advanced/mattermost/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/mattermost/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/14/Makefile b/linux/advanced/nextcloud/patched/14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/14/Makefile +++ b/linux/advanced/nextcloud/patched/14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/14/kaniko-build.py b/linux/advanced/nextcloud/patched/14/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/14/requirements.txt b/linux/advanced/nextcloud/patched/14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/15/Makefile b/linux/advanced/nextcloud/patched/15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/15/Makefile +++ b/linux/advanced/nextcloud/patched/15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/15/kaniko-build.py b/linux/advanced/nextcloud/patched/15/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/15/requirements.txt b/linux/advanced/nextcloud/patched/15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/16/Makefile b/linux/advanced/nextcloud/patched/16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/16/Makefile +++ b/linux/advanced/nextcloud/patched/16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/16/kaniko-build.py b/linux/advanced/nextcloud/patched/16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/16/requirements.txt b/linux/advanced/nextcloud/patched/16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/17/Makefile b/linux/advanced/nextcloud/patched/17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/17/Makefile +++ b/linux/advanced/nextcloud/patched/17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/17/kaniko-build.py b/linux/advanced/nextcloud/patched/17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/17/requirements.txt b/linux/advanced/nextcloud/patched/17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/18/Makefile b/linux/advanced/nextcloud/patched/18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/18/Makefile +++ b/linux/advanced/nextcloud/patched/18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/18/kaniko-build.py b/linux/advanced/nextcloud/patched/18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/18/requirements.txt b/linux/advanced/nextcloud/patched/18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/19/Makefile b/linux/advanced/nextcloud/patched/19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/19/Makefile +++ b/linux/advanced/nextcloud/patched/19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/19/kaniko-build.py b/linux/advanced/nextcloud/patched/19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/19/requirements.txt b/linux/advanced/nextcloud/patched/19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/20/Makefile b/linux/advanced/nextcloud/patched/20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/20/Makefile +++ b/linux/advanced/nextcloud/patched/20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/20/kaniko-build.py b/linux/advanced/nextcloud/patched/20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/20/requirements.txt b/linux/advanced/nextcloud/patched/20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/21/Makefile b/linux/advanced/nextcloud/patched/21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/21/Makefile +++ b/linux/advanced/nextcloud/patched/21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/21/kaniko-build.py b/linux/advanced/nextcloud/patched/21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/21/requirements.txt b/linux/advanced/nextcloud/patched/21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/22/Makefile b/linux/advanced/nextcloud/patched/22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/22/Makefile +++ b/linux/advanced/nextcloud/patched/22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/22/kaniko-build.py b/linux/advanced/nextcloud/patched/22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/22/requirements.txt b/linux/advanced/nextcloud/patched/22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/23/Makefile b/linux/advanced/nextcloud/patched/23/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/23/Makefile +++ b/linux/advanced/nextcloud/patched/23/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/23/kaniko-build.py b/linux/advanced/nextcloud/patched/23/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/23/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/23/requirements.txt b/linux/advanced/nextcloud/patched/23/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/23/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/24/Makefile b/linux/advanced/nextcloud/patched/24/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/24/Makefile +++ b/linux/advanced/nextcloud/patched/24/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/24/kaniko-build.py b/linux/advanced/nextcloud/patched/24/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/24/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/24/requirements.txt b/linux/advanced/nextcloud/patched/24/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/24/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/25/Makefile b/linux/advanced/nextcloud/patched/25/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/25/Makefile +++ b/linux/advanced/nextcloud/patched/25/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/25/kaniko-build.py b/linux/advanced/nextcloud/patched/25/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/25/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/25/requirements.txt b/linux/advanced/nextcloud/patched/25/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/25/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/26/Makefile b/linux/advanced/nextcloud/patched/26/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/26/Makefile +++ b/linux/advanced/nextcloud/patched/26/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/26/kaniko-build.py b/linux/advanced/nextcloud/patched/26/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/26/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/26/requirements.txt b/linux/advanced/nextcloud/patched/26/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/26/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/27/Makefile b/linux/advanced/nextcloud/patched/27/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/27/Makefile +++ b/linux/advanced/nextcloud/patched/27/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/27/kaniko-build.py b/linux/advanced/nextcloud/patched/27/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/27/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/27/requirements.txt b/linux/advanced/nextcloud/patched/27/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/27/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/28/Makefile b/linux/advanced/nextcloud/patched/28/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/28/Makefile +++ b/linux/advanced/nextcloud/patched/28/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/28/kaniko-build.py b/linux/advanced/nextcloud/patched/28/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/28/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/28/requirements.txt b/linux/advanced/nextcloud/patched/28/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/28/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/29/Makefile b/linux/advanced/nextcloud/patched/29/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/29/Makefile +++ b/linux/advanced/nextcloud/patched/29/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/29/kaniko-build.py b/linux/advanced/nextcloud/patched/29/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/29/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/29/requirements.txt b/linux/advanced/nextcloud/patched/29/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/29/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/patched/latest/Makefile b/linux/advanced/nextcloud/patched/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/patched/latest/Makefile +++ b/linux/advanced/nextcloud/patched/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/patched/latest/kaniko-build.py b/linux/advanced/nextcloud/patched/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/patched/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/patched/latest/requirements.txt b/linux/advanced/nextcloud/patched/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/patched/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/14/Makefile b/linux/advanced/nextcloud/pure/14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/14/Makefile +++ b/linux/advanced/nextcloud/pure/14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/14/kaniko-build.py b/linux/advanced/nextcloud/pure/14/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/14/requirements.txt b/linux/advanced/nextcloud/pure/14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/15/Makefile b/linux/advanced/nextcloud/pure/15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/15/Makefile +++ b/linux/advanced/nextcloud/pure/15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/15/kaniko-build.py b/linux/advanced/nextcloud/pure/15/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/15/requirements.txt b/linux/advanced/nextcloud/pure/15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/16/Makefile b/linux/advanced/nextcloud/pure/16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/16/Makefile +++ b/linux/advanced/nextcloud/pure/16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/16/kaniko-build.py b/linux/advanced/nextcloud/pure/16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/16/requirements.txt b/linux/advanced/nextcloud/pure/16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/17/Makefile b/linux/advanced/nextcloud/pure/17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/17/Makefile +++ b/linux/advanced/nextcloud/pure/17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/17/kaniko-build.py b/linux/advanced/nextcloud/pure/17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/17/requirements.txt b/linux/advanced/nextcloud/pure/17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/18/Makefile b/linux/advanced/nextcloud/pure/18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/18/Makefile +++ b/linux/advanced/nextcloud/pure/18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/18/kaniko-build.py b/linux/advanced/nextcloud/pure/18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/18/requirements.txt b/linux/advanced/nextcloud/pure/18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/19/Makefile b/linux/advanced/nextcloud/pure/19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/19/Makefile +++ b/linux/advanced/nextcloud/pure/19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/19/kaniko-build.py b/linux/advanced/nextcloud/pure/19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/19/requirements.txt b/linux/advanced/nextcloud/pure/19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/20/Makefile b/linux/advanced/nextcloud/pure/20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/20/Makefile +++ b/linux/advanced/nextcloud/pure/20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/20/kaniko-build.py b/linux/advanced/nextcloud/pure/20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/20/requirements.txt b/linux/advanced/nextcloud/pure/20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/21/Makefile b/linux/advanced/nextcloud/pure/21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/21/Makefile +++ b/linux/advanced/nextcloud/pure/21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/21/kaniko-build.py b/linux/advanced/nextcloud/pure/21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/21/requirements.txt b/linux/advanced/nextcloud/pure/21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/22/Makefile b/linux/advanced/nextcloud/pure/22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/22/Makefile +++ b/linux/advanced/nextcloud/pure/22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/22/kaniko-build.py b/linux/advanced/nextcloud/pure/22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/22/requirements.txt b/linux/advanced/nextcloud/pure/22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/23/Makefile b/linux/advanced/nextcloud/pure/23/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/23/Makefile +++ b/linux/advanced/nextcloud/pure/23/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/23/kaniko-build.py b/linux/advanced/nextcloud/pure/23/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/23/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/23/requirements.txt b/linux/advanced/nextcloud/pure/23/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/23/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/24/Makefile b/linux/advanced/nextcloud/pure/24/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/24/Makefile +++ b/linux/advanced/nextcloud/pure/24/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/24/kaniko-build.py b/linux/advanced/nextcloud/pure/24/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/24/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/24/requirements.txt b/linux/advanced/nextcloud/pure/24/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/24/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/25/Makefile b/linux/advanced/nextcloud/pure/25/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/25/Makefile +++ b/linux/advanced/nextcloud/pure/25/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/25/kaniko-build.py b/linux/advanced/nextcloud/pure/25/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/25/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/25/requirements.txt b/linux/advanced/nextcloud/pure/25/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/25/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/26/Makefile b/linux/advanced/nextcloud/pure/26/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/26/Makefile +++ b/linux/advanced/nextcloud/pure/26/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/26/kaniko-build.py b/linux/advanced/nextcloud/pure/26/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/26/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/26/requirements.txt b/linux/advanced/nextcloud/pure/26/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/26/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/27/Makefile b/linux/advanced/nextcloud/pure/27/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/27/Makefile +++ b/linux/advanced/nextcloud/pure/27/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/27/kaniko-build.py b/linux/advanced/nextcloud/pure/27/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/27/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/27/requirements.txt b/linux/advanced/nextcloud/pure/27/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/27/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/28/Makefile b/linux/advanced/nextcloud/pure/28/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/28/Makefile +++ b/linux/advanced/nextcloud/pure/28/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/28/kaniko-build.py b/linux/advanced/nextcloud/pure/28/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/28/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/28/requirements.txt b/linux/advanced/nextcloud/pure/28/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/28/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/29/Makefile b/linux/advanced/nextcloud/pure/29/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/29/Makefile +++ b/linux/advanced/nextcloud/pure/29/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/29/kaniko-build.py b/linux/advanced/nextcloud/pure/29/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/29/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/29/requirements.txt b/linux/advanced/nextcloud/pure/29/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/29/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/nextcloud/pure/latest/Makefile b/linux/advanced/nextcloud/pure/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/nextcloud/pure/latest/Makefile +++ b/linux/advanced/nextcloud/pure/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/nextcloud/pure/latest/kaniko-build.py b/linux/advanced/nextcloud/pure/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/nextcloud/pure/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/nextcloud/pure/latest/requirements.txt b/linux/advanced/nextcloud/pure/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/nextcloud/pure/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/2.7/Makefile b/linux/advanced/python/develop/2.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/2.7/Makefile +++ b/linux/advanced/python/develop/2.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/2.7/kaniko-build.py b/linux/advanced/python/develop/2.7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/2.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/2.7/requirements.txt b/linux/advanced/python/develop/2.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/2.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.10/Makefile b/linux/advanced/python/develop/3.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.10/Makefile +++ b/linux/advanced/python/develop/3.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.10/kaniko-build.py b/linux/advanced/python/develop/3.10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.10/requirements.txt b/linux/advanced/python/develop/3.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.11/Makefile b/linux/advanced/python/develop/3.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.11/Makefile +++ b/linux/advanced/python/develop/3.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.11/kaniko-build.py b/linux/advanced/python/develop/3.11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.11/requirements.txt b/linux/advanced/python/develop/3.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.12/Makefile b/linux/advanced/python/develop/3.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.12/Makefile +++ b/linux/advanced/python/develop/3.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.12/kaniko-build.py b/linux/advanced/python/develop/3.12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.12/requirements.txt b/linux/advanced/python/develop/3.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.13/Makefile b/linux/advanced/python/develop/3.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.13/Makefile +++ b/linux/advanced/python/develop/3.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.13/kaniko-build.py b/linux/advanced/python/develop/3.13/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.13/requirements.txt b/linux/advanced/python/develop/3.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.6/Makefile b/linux/advanced/python/develop/3.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.6/Makefile +++ b/linux/advanced/python/develop/3.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.6/kaniko-build.py b/linux/advanced/python/develop/3.6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.6/requirements.txt b/linux/advanced/python/develop/3.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.7/Makefile b/linux/advanced/python/develop/3.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.7/Makefile +++ b/linux/advanced/python/develop/3.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.7/kaniko-build.py b/linux/advanced/python/develop/3.7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.7/requirements.txt b/linux/advanced/python/develop/3.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.8/Makefile b/linux/advanced/python/develop/3.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.8/Makefile +++ b/linux/advanced/python/develop/3.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.8/kaniko-build.py b/linux/advanced/python/develop/3.8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.8/requirements.txt b/linux/advanced/python/develop/3.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/develop/3.9/Makefile b/linux/advanced/python/develop/3.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/develop/3.9/Makefile +++ b/linux/advanced/python/develop/3.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/develop/3.9/kaniko-build.py b/linux/advanced/python/develop/3.9/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/develop/3.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/develop/3.9/requirements.txt b/linux/advanced/python/develop/3.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/develop/3.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/2.7/Makefile b/linux/advanced/python/main/2.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/2.7/Makefile +++ b/linux/advanced/python/main/2.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/2.7/kaniko-build.py b/linux/advanced/python/main/2.7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/2.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/2.7/requirements.txt b/linux/advanced/python/main/2.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/2.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.10/Makefile b/linux/advanced/python/main/3.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.10/Makefile +++ b/linux/advanced/python/main/3.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.10/kaniko-build.py b/linux/advanced/python/main/3.10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.10/requirements.txt b/linux/advanced/python/main/3.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.11/Makefile b/linux/advanced/python/main/3.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.11/Makefile +++ b/linux/advanced/python/main/3.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.11/kaniko-build.py b/linux/advanced/python/main/3.11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.11/requirements.txt b/linux/advanced/python/main/3.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.12/Makefile b/linux/advanced/python/main/3.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.12/Makefile +++ b/linux/advanced/python/main/3.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.12/kaniko-build.py b/linux/advanced/python/main/3.12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.12/requirements.txt b/linux/advanced/python/main/3.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.13/Makefile b/linux/advanced/python/main/3.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.13/Makefile +++ b/linux/advanced/python/main/3.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.13/kaniko-build.py b/linux/advanced/python/main/3.13/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.13/requirements.txt b/linux/advanced/python/main/3.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.6/Makefile b/linux/advanced/python/main/3.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.6/Makefile +++ b/linux/advanced/python/main/3.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.6/kaniko-build.py b/linux/advanced/python/main/3.6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.6/requirements.txt b/linux/advanced/python/main/3.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.7/Makefile b/linux/advanced/python/main/3.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.7/Makefile +++ b/linux/advanced/python/main/3.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.7/kaniko-build.py b/linux/advanced/python/main/3.7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.7/requirements.txt b/linux/advanced/python/main/3.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.8/Makefile b/linux/advanced/python/main/3.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.8/Makefile +++ b/linux/advanced/python/main/3.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.8/kaniko-build.py b/linux/advanced/python/main/3.8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.8/requirements.txt b/linux/advanced/python/main/3.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/python/main/3.9/Makefile b/linux/advanced/python/main/3.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/python/main/3.9/Makefile +++ b/linux/advanced/python/main/3.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/python/main/3.9/kaniko-build.py b/linux/advanced/python/main/3.9/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/python/main/3.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/python/main/3.9/requirements.txt b/linux/advanced/python/main/3.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/python/main/3.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/redash/Makefile b/linux/advanced/redash/Makefile index 79f8a5cec..4188e2174 100644 --- a/linux/advanced/redash/Makefile +++ b/linux/advanced/redash/Makefile @@ -17,9 +17,32 @@ patch: sed -i -e 's/# ldap3==2.2.4/ldap3==2.2.4/g' ./redash-repo/requirements.txt 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/sentry/latest/Makefile b/linux/advanced/sentry/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/sentry/latest/Makefile +++ b/linux/advanced/sentry/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/sentry/latest/kaniko-build.py b/linux/advanced/sentry/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/sentry/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/sentry/latest/requirements.txt b/linux/advanced/sentry/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/sentry/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/teamcity/server/Makefile b/linux/advanced/teamcity/server/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/teamcity/server/Makefile +++ b/linux/advanced/teamcity/server/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/teamcity/server/kaniko-build.py b/linux/advanced/teamcity/server/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/teamcity/server/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/teamcity/server/requirements.txt b/linux/advanced/teamcity/server/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/teamcity/server/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/amxx/1.10/Makefile b/linux/advanced/vscode-server/amxx/1.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/amxx/1.10/Makefile +++ b/linux/advanced/vscode-server/amxx/1.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/amxx/1.10/kaniko-build.py b/linux/advanced/vscode-server/amxx/1.10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/amxx/1.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/amxx/1.10/requirements.txt b/linux/advanced/vscode-server/amxx/1.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/amxx/1.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/amxx/1.9/Makefile b/linux/advanced/vscode-server/amxx/1.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/amxx/1.9/Makefile +++ b/linux/advanced/vscode-server/amxx/1.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/amxx/1.9/kaniko-build.py b/linux/advanced/vscode-server/amxx/1.9/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/amxx/1.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/amxx/1.9/requirements.txt b/linux/advanced/vscode-server/amxx/1.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/amxx/1.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/android/Makefile b/linux/advanced/vscode-server/android/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/android/Makefile +++ b/linux/advanced/vscode-server/android/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/android/kaniko-build.py b/linux/advanced/vscode-server/android/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/android/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/android/requirements.txt b/linux/advanced/vscode-server/android/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/android/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/cpp/Makefile b/linux/advanced/vscode-server/cpp/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/cpp/Makefile +++ b/linux/advanced/vscode-server/cpp/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/cpp/kaniko-build.py b/linux/advanced/vscode-server/cpp/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/cpp/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/cpp/requirements.txt b/linux/advanced/vscode-server/cpp/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/cpp/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/devops/Makefile b/linux/advanced/vscode-server/devops/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/devops/Makefile +++ b/linux/advanced/vscode-server/devops/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/devops/kaniko-build.py b/linux/advanced/vscode-server/devops/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/devops/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/devops/requirements.txt b/linux/advanced/vscode-server/devops/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/devops/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/docker/Makefile b/linux/advanced/vscode-server/docker/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/docker/Makefile +++ b/linux/advanced/vscode-server/docker/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/docker/kaniko-build.py b/linux/advanced/vscode-server/docker/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/docker/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/docker/requirements.txt b/linux/advanced/vscode-server/docker/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/docker/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/dotnet-full/Makefile b/linux/advanced/vscode-server/dotnet-full/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/dotnet-full/Makefile +++ b/linux/advanced/vscode-server/dotnet-full/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/dotnet-full/kaniko-build.py b/linux/advanced/vscode-server/dotnet-full/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/dotnet-full/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/dotnet-full/requirements.txt b/linux/advanced/vscode-server/dotnet-full/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/dotnet-full/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/dotnet/Makefile b/linux/advanced/vscode-server/dotnet/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/dotnet/Makefile +++ b/linux/advanced/vscode-server/dotnet/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/dotnet/kaniko-build.py b/linux/advanced/vscode-server/dotnet/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/dotnet/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/dotnet/requirements.txt b/linux/advanced/vscode-server/dotnet/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/dotnet/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/latest/Makefile b/linux/advanced/vscode-server/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/latest/Makefile +++ b/linux/advanced/vscode-server/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/latest/kaniko-build.py b/linux/advanced/vscode-server/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/latest/requirements.txt b/linux/advanced/vscode-server/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/vscode-server/mono/Makefile b/linux/advanced/vscode-server/mono/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/vscode-server/mono/Makefile +++ b/linux/advanced/vscode-server/mono/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/vscode-server/mono/kaniko-build.py b/linux/advanced/vscode-server/mono/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/vscode-server/mono/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/vscode-server/mono/requirements.txt b/linux/advanced/vscode-server/mono/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/vscode-server/mono/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/agent/Makefile b/linux/advanced/zabbix/3.0/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/agent/Makefile +++ b/linux/advanced/zabbix/3.0/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/agent/kaniko-build.py b/linux/advanced/zabbix/3.0/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/agent/requirements.txt b/linux/advanced/zabbix/3.0/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/java-gateway/Makefile b/linux/advanced/zabbix/3.0/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/3.0/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/java-gateway/requirements.txt b/linux/advanced/zabbix/3.0/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/proxy-mysql/Makefile b/linux/advanced/zabbix/3.0/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/3.0/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/server-mysql/Makefile b/linux/advanced/zabbix/3.0/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/3.0/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/server-mysql/requirements.txt b/linux/advanced/zabbix/3.0/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/server-pgsql/Makefile b/linux/advanced/zabbix/3.0/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/3.0/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/snmptraps/Makefile b/linux/advanced/zabbix/3.0/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/3.0/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/snmptraps/requirements.txt b/linux/advanced/zabbix/3.0/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/web-mysql/Makefile b/linux/advanced/zabbix/3.0/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/3.0/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/web-mysql/requirements.txt b/linux/advanced/zabbix/3.0/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/3.0/web-pgsql/Makefile b/linux/advanced/zabbix/3.0/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/3.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/3.0/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/agent/Makefile b/linux/advanced/zabbix/4.0/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/agent/Makefile +++ b/linux/advanced/zabbix/4.0/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/agent/kaniko-build.py b/linux/advanced/zabbix/4.0/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/agent/requirements.txt b/linux/advanced/zabbix/4.0/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/java-gateway/Makefile b/linux/advanced/zabbix/4.0/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/4.0/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/java-gateway/requirements.txt b/linux/advanced/zabbix/4.0/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/proxy-mysql/Makefile b/linux/advanced/zabbix/4.0/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/4.0/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/server-mysql/Makefile b/linux/advanced/zabbix/4.0/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/4.0/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/server-mysql/requirements.txt b/linux/advanced/zabbix/4.0/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/server-pgsql/Makefile b/linux/advanced/zabbix/4.0/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/4.0/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/snmptraps/Makefile b/linux/advanced/zabbix/4.0/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/4.0/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/snmptraps/requirements.txt b/linux/advanced/zabbix/4.0/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/web-mysql/Makefile b/linux/advanced/zabbix/4.0/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/4.0/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/web-mysql/requirements.txt b/linux/advanced/zabbix/4.0/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/4.0/web-pgsql/Makefile b/linux/advanced/zabbix/4.0/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/4.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/4.0/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/agent/Makefile b/linux/advanced/zabbix/5.0/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/agent/Makefile +++ b/linux/advanced/zabbix/5.0/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/agent/kaniko-build.py b/linux/advanced/zabbix/5.0/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/agent/requirements.txt b/linux/advanced/zabbix/5.0/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/agent2/Makefile b/linux/advanced/zabbix/5.0/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/agent2/Makefile +++ b/linux/advanced/zabbix/5.0/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/agent2/kaniko-build.py b/linux/advanced/zabbix/5.0/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/agent2/requirements.txt b/linux/advanced/zabbix/5.0/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/java-gateway/Makefile b/linux/advanced/zabbix/5.0/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/5.0/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/java-gateway/requirements.txt b/linux/advanced/zabbix/5.0/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/proxy-mysql/Makefile b/linux/advanced/zabbix/5.0/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/5.0/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/server-mysql/Makefile b/linux/advanced/zabbix/5.0/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/5.0/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/server-mysql/requirements.txt b/linux/advanced/zabbix/5.0/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/server-pgsql/Makefile b/linux/advanced/zabbix/5.0/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/5.0/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/snmptraps/Makefile b/linux/advanced/zabbix/5.0/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/5.0/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/snmptraps/requirements.txt b/linux/advanced/zabbix/5.0/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/web-mysql/Makefile b/linux/advanced/zabbix/5.0/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/5.0/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/web-mysql/requirements.txt b/linux/advanced/zabbix/5.0/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.0/web-pgsql/Makefile b/linux/advanced/zabbix/5.0/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/5.0/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/agent/Makefile b/linux/advanced/zabbix/5.2/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/agent/Makefile +++ b/linux/advanced/zabbix/5.2/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/agent/kaniko-build.py b/linux/advanced/zabbix/5.2/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/agent/requirements.txt b/linux/advanced/zabbix/5.2/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/agent2/Makefile b/linux/advanced/zabbix/5.2/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/agent2/Makefile +++ b/linux/advanced/zabbix/5.2/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/agent2/kaniko-build.py b/linux/advanced/zabbix/5.2/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/agent2/requirements.txt b/linux/advanced/zabbix/5.2/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/java-gateway/Makefile b/linux/advanced/zabbix/5.2/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/java-gateway/Makefile +++ b/linux/advanced/zabbix/5.2/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py b/linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/java-gateway/requirements.txt b/linux/advanced/zabbix/5.2/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/proxy-mysql/Makefile b/linux/advanced/zabbix/5.2/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/5.2/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt b/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile b/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/server-mysql/Makefile b/linux/advanced/zabbix/5.2/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/server-mysql/Makefile +++ b/linux/advanced/zabbix/5.2/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py b/linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/server-mysql/requirements.txt b/linux/advanced/zabbix/5.2/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/server-pgsql/Makefile b/linux/advanced/zabbix/5.2/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/server-pgsql/Makefile +++ b/linux/advanced/zabbix/5.2/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt b/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/snmptraps/Makefile b/linux/advanced/zabbix/5.2/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/snmptraps/Makefile +++ b/linux/advanced/zabbix/5.2/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py b/linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/snmptraps/requirements.txt b/linux/advanced/zabbix/5.2/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/web-mysql/Makefile b/linux/advanced/zabbix/5.2/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/web-mysql/Makefile +++ b/linux/advanced/zabbix/5.2/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py b/linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/web-mysql/requirements.txt b/linux/advanced/zabbix/5.2/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.2/web-pgsql/Makefile b/linux/advanced/zabbix/5.2/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.2/web-pgsql/Makefile +++ b/linux/advanced/zabbix/5.2/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt b/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/agent/Makefile b/linux/advanced/zabbix/5.4/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/agent/Makefile +++ b/linux/advanced/zabbix/5.4/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/agent/kaniko-build.py b/linux/advanced/zabbix/5.4/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/agent/requirements.txt b/linux/advanced/zabbix/5.4/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/agent2/Makefile b/linux/advanced/zabbix/5.4/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/agent2/Makefile +++ b/linux/advanced/zabbix/5.4/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/agent2/kaniko-build.py b/linux/advanced/zabbix/5.4/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/agent2/requirements.txt b/linux/advanced/zabbix/5.4/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/java-gateway/Makefile b/linux/advanced/zabbix/5.4/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/java-gateway/Makefile +++ b/linux/advanced/zabbix/5.4/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py b/linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/java-gateway/requirements.txt b/linux/advanced/zabbix/5.4/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/proxy-mysql/Makefile b/linux/advanced/zabbix/5.4/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/5.4/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt b/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile b/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/server-mysql/Makefile b/linux/advanced/zabbix/5.4/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/server-mysql/Makefile +++ b/linux/advanced/zabbix/5.4/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py b/linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/server-mysql/requirements.txt b/linux/advanced/zabbix/5.4/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/server-pgsql/Makefile b/linux/advanced/zabbix/5.4/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/server-pgsql/Makefile +++ b/linux/advanced/zabbix/5.4/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt b/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/snmptraps/Makefile b/linux/advanced/zabbix/5.4/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/snmptraps/Makefile +++ b/linux/advanced/zabbix/5.4/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py b/linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/snmptraps/requirements.txt b/linux/advanced/zabbix/5.4/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/web-mysql/Makefile b/linux/advanced/zabbix/5.4/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/web-mysql/Makefile +++ b/linux/advanced/zabbix/5.4/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py b/linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/web-mysql/requirements.txt b/linux/advanced/zabbix/5.4/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/5.4/web-pgsql/Makefile b/linux/advanced/zabbix/5.4/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/5.4/web-pgsql/Makefile +++ b/linux/advanced/zabbix/5.4/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt b/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/agent/Makefile b/linux/advanced/zabbix/6.0/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/agent/Makefile +++ b/linux/advanced/zabbix/6.0/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/agent/kaniko-build.py b/linux/advanced/zabbix/6.0/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/agent/requirements.txt b/linux/advanced/zabbix/6.0/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/agent2/Makefile b/linux/advanced/zabbix/6.0/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/agent2/Makefile +++ b/linux/advanced/zabbix/6.0/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/agent2/kaniko-build.py b/linux/advanced/zabbix/6.0/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/agent2/requirements.txt b/linux/advanced/zabbix/6.0/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/java-gateway/Makefile b/linux/advanced/zabbix/6.0/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/6.0/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/java-gateway/requirements.txt b/linux/advanced/zabbix/6.0/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/proxy-mysql/Makefile b/linux/advanced/zabbix/6.0/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/6.0/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/server-mysql/Makefile b/linux/advanced/zabbix/6.0/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/6.0/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/server-mysql/requirements.txt b/linux/advanced/zabbix/6.0/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/server-pgsql/Makefile b/linux/advanced/zabbix/6.0/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/6.0/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/snmptraps/Makefile b/linux/advanced/zabbix/6.0/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/6.0/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/snmptraps/requirements.txt b/linux/advanced/zabbix/6.0/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/web-mysql/Makefile b/linux/advanced/zabbix/6.0/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/6.0/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/web-mysql/requirements.txt b/linux/advanced/zabbix/6.0/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.0/web-pgsql/Makefile b/linux/advanced/zabbix/6.0/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/6.0/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/agent/Makefile b/linux/advanced/zabbix/6.2/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/agent/Makefile +++ b/linux/advanced/zabbix/6.2/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/agent/kaniko-build.py b/linux/advanced/zabbix/6.2/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/agent/requirements.txt b/linux/advanced/zabbix/6.2/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/agent2/Makefile b/linux/advanced/zabbix/6.2/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/agent2/Makefile +++ b/linux/advanced/zabbix/6.2/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/agent2/kaniko-build.py b/linux/advanced/zabbix/6.2/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/agent2/requirements.txt b/linux/advanced/zabbix/6.2/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/java-gateway/Makefile b/linux/advanced/zabbix/6.2/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/java-gateway/Makefile +++ b/linux/advanced/zabbix/6.2/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py b/linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/java-gateway/requirements.txt b/linux/advanced/zabbix/6.2/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/proxy-mysql/Makefile b/linux/advanced/zabbix/6.2/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/6.2/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt b/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile b/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/server-mysql/Makefile b/linux/advanced/zabbix/6.2/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/server-mysql/Makefile +++ b/linux/advanced/zabbix/6.2/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py b/linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/server-mysql/requirements.txt b/linux/advanced/zabbix/6.2/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/server-pgsql/Makefile b/linux/advanced/zabbix/6.2/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/server-pgsql/Makefile +++ b/linux/advanced/zabbix/6.2/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt b/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/snmptraps/Makefile b/linux/advanced/zabbix/6.2/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/snmptraps/Makefile +++ b/linux/advanced/zabbix/6.2/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py b/linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/snmptraps/requirements.txt b/linux/advanced/zabbix/6.2/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/web-mysql/Makefile b/linux/advanced/zabbix/6.2/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/web-mysql/Makefile +++ b/linux/advanced/zabbix/6.2/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py b/linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/web-mysql/requirements.txt b/linux/advanced/zabbix/6.2/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.2/web-pgsql/Makefile b/linux/advanced/zabbix/6.2/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.2/web-pgsql/Makefile +++ b/linux/advanced/zabbix/6.2/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt b/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/agent/Makefile b/linux/advanced/zabbix/6.4/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/agent/Makefile +++ b/linux/advanced/zabbix/6.4/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/agent/kaniko-build.py b/linux/advanced/zabbix/6.4/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/agent/requirements.txt b/linux/advanced/zabbix/6.4/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/agent2/Makefile b/linux/advanced/zabbix/6.4/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/agent2/Makefile +++ b/linux/advanced/zabbix/6.4/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/agent2/kaniko-build.py b/linux/advanced/zabbix/6.4/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/agent2/requirements.txt b/linux/advanced/zabbix/6.4/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/java-gateway/Makefile b/linux/advanced/zabbix/6.4/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/java-gateway/Makefile +++ b/linux/advanced/zabbix/6.4/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py b/linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/java-gateway/requirements.txt b/linux/advanced/zabbix/6.4/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/proxy-mysql/Makefile b/linux/advanced/zabbix/6.4/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/6.4/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt b/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile b/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/server-mysql/Makefile b/linux/advanced/zabbix/6.4/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/server-mysql/Makefile +++ b/linux/advanced/zabbix/6.4/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py b/linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/server-mysql/requirements.txt b/linux/advanced/zabbix/6.4/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/server-pgsql/Makefile b/linux/advanced/zabbix/6.4/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/server-pgsql/Makefile +++ b/linux/advanced/zabbix/6.4/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt b/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/snmptraps/Makefile b/linux/advanced/zabbix/6.4/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/snmptraps/Makefile +++ b/linux/advanced/zabbix/6.4/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py b/linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/snmptraps/requirements.txt b/linux/advanced/zabbix/6.4/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/web-mysql/Makefile b/linux/advanced/zabbix/6.4/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/web-mysql/Makefile +++ b/linux/advanced/zabbix/6.4/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py b/linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/web-mysql/requirements.txt b/linux/advanced/zabbix/6.4/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/6.4/web-pgsql/Makefile b/linux/advanced/zabbix/6.4/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/6.4/web-pgsql/Makefile +++ b/linux/advanced/zabbix/6.4/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt b/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/agent/Makefile b/linux/advanced/zabbix/latest/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/agent/Makefile +++ b/linux/advanced/zabbix/latest/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/agent/kaniko-build.py b/linux/advanced/zabbix/latest/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/agent/requirements.txt b/linux/advanced/zabbix/latest/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/agent2/Makefile b/linux/advanced/zabbix/latest/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/agent2/Makefile +++ b/linux/advanced/zabbix/latest/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/agent2/kaniko-build.py b/linux/advanced/zabbix/latest/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/agent2/requirements.txt b/linux/advanced/zabbix/latest/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/java-gateway/Makefile b/linux/advanced/zabbix/latest/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/java-gateway/Makefile +++ b/linux/advanced/zabbix/latest/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/java-gateway/kaniko-build.py b/linux/advanced/zabbix/latest/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/java-gateway/requirements.txt b/linux/advanced/zabbix/latest/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/proxy-mysql/Makefile b/linux/advanced/zabbix/latest/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/latest/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt b/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile b/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/server-mysql/Makefile b/linux/advanced/zabbix/latest/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/server-mysql/Makefile +++ b/linux/advanced/zabbix/latest/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/server-mysql/kaniko-build.py b/linux/advanced/zabbix/latest/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/server-mysql/requirements.txt b/linux/advanced/zabbix/latest/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/server-pgsql/Makefile b/linux/advanced/zabbix/latest/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/server-pgsql/Makefile +++ b/linux/advanced/zabbix/latest/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/server-pgsql/requirements.txt b/linux/advanced/zabbix/latest/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/snmptraps/Makefile b/linux/advanced/zabbix/latest/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/snmptraps/Makefile +++ b/linux/advanced/zabbix/latest/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/snmptraps/kaniko-build.py b/linux/advanced/zabbix/latest/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/snmptraps/requirements.txt b/linux/advanced/zabbix/latest/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/web-mysql/Makefile b/linux/advanced/zabbix/latest/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/web-mysql/Makefile +++ b/linux/advanced/zabbix/latest/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/web-mysql/kaniko-build.py b/linux/advanced/zabbix/latest/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/web-mysql/requirements.txt b/linux/advanced/zabbix/latest/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/latest/web-pgsql/Makefile b/linux/advanced/zabbix/latest/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/latest/web-pgsql/Makefile +++ b/linux/advanced/zabbix/latest/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/latest/web-pgsql/requirements.txt b/linux/advanced/zabbix/latest/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/latest/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/agent/Makefile b/linux/advanced/zabbix/trunk/agent/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/agent/Makefile +++ b/linux/advanced/zabbix/trunk/agent/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/agent/kaniko-build.py b/linux/advanced/zabbix/trunk/agent/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/agent/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/agent/requirements.txt b/linux/advanced/zabbix/trunk/agent/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/agent/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/agent2/Makefile b/linux/advanced/zabbix/trunk/agent2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/agent2/Makefile +++ b/linux/advanced/zabbix/trunk/agent2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/agent2/kaniko-build.py b/linux/advanced/zabbix/trunk/agent2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/agent2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/agent2/requirements.txt b/linux/advanced/zabbix/trunk/agent2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/agent2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/java-gateway/Makefile b/linux/advanced/zabbix/trunk/java-gateway/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/java-gateway/Makefile +++ b/linux/advanced/zabbix/trunk/java-gateway/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py b/linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/java-gateway/requirements.txt b/linux/advanced/zabbix/trunk/java-gateway/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/java-gateway/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/proxy-mysql/Makefile b/linux/advanced/zabbix/trunk/proxy-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/trunk/proxy-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt b/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile b/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/server-mysql/Makefile b/linux/advanced/zabbix/trunk/server-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/server-mysql/Makefile +++ b/linux/advanced/zabbix/trunk/server-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py b/linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/server-mysql/requirements.txt b/linux/advanced/zabbix/trunk/server-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/server-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/server-pgsql/Makefile b/linux/advanced/zabbix/trunk/server-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/server-pgsql/Makefile +++ b/linux/advanced/zabbix/trunk/server-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt b/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/snmptraps/Makefile b/linux/advanced/zabbix/trunk/snmptraps/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/snmptraps/Makefile +++ b/linux/advanced/zabbix/trunk/snmptraps/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py b/linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/snmptraps/requirements.txt b/linux/advanced/zabbix/trunk/snmptraps/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/snmptraps/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/web-mysql/Makefile b/linux/advanced/zabbix/trunk/web-mysql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/web-mysql/Makefile +++ b/linux/advanced/zabbix/trunk/web-mysql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py b/linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/web-mysql/requirements.txt b/linux/advanced/zabbix/trunk/web-mysql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/web-mysql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/advanced/zabbix/trunk/web-pgsql/Makefile b/linux/advanced/zabbix/trunk/web-pgsql/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/advanced/zabbix/trunk/web-pgsql/Makefile +++ b/linux/advanced/zabbix/trunk/web-pgsql/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt b/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile index bad6d73b5..44c0a1e5e 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile b/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py b/linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt b/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php5.5/Makefile b/linux/ecosystem/apache2/php5.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php5.5/Makefile +++ b/linux/ecosystem/apache2/php5.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php5.5/kaniko-build.py b/linux/ecosystem/apache2/php5.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php5.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php5.5/requirements.txt b/linux/ecosystem/apache2/php5.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php5.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php7.0/Makefile b/linux/ecosystem/apache2/php7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php7.0/Makefile +++ b/linux/ecosystem/apache2/php7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php7.0/kaniko-build.py b/linux/ecosystem/apache2/php7.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php7.0/requirements.txt b/linux/ecosystem/apache2/php7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php7.1/Makefile b/linux/ecosystem/apache2/php7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php7.1/Makefile +++ b/linux/ecosystem/apache2/php7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php7.1/kaniko-build.py b/linux/ecosystem/apache2/php7.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php7.1/requirements.txt b/linux/ecosystem/apache2/php7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php7.2/Makefile b/linux/ecosystem/apache2/php7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php7.2/Makefile +++ b/linux/ecosystem/apache2/php7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php7.2/kaniko-build.py b/linux/ecosystem/apache2/php7.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php7.2/requirements.txt b/linux/ecosystem/apache2/php7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php7.3/Makefile b/linux/ecosystem/apache2/php7.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php7.3/Makefile +++ b/linux/ecosystem/apache2/php7.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php7.3/kaniko-build.py b/linux/ecosystem/apache2/php7.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php7.3/requirements.txt b/linux/ecosystem/apache2/php7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php7.4/Makefile b/linux/ecosystem/apache2/php7.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php7.4/Makefile +++ b/linux/ecosystem/apache2/php7.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php7.4/kaniko-build.py b/linux/ecosystem/apache2/php7.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php7.4/requirements.txt b/linux/ecosystem/apache2/php7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php8.0/Makefile b/linux/ecosystem/apache2/php8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php8.0/Makefile +++ b/linux/ecosystem/apache2/php8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php8.0/kaniko-build.py b/linux/ecosystem/apache2/php8.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php8.0/requirements.txt b/linux/ecosystem/apache2/php8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php8.1/Makefile b/linux/ecosystem/apache2/php8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php8.1/Makefile +++ b/linux/ecosystem/apache2/php8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php8.1/kaniko-build.py b/linux/ecosystem/apache2/php8.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php8.1/requirements.txt b/linux/ecosystem/apache2/php8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php8.2/Makefile b/linux/ecosystem/apache2/php8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php8.2/Makefile +++ b/linux/ecosystem/apache2/php8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php8.2/kaniko-build.py b/linux/ecosystem/apache2/php8.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php8.2/requirements.txt b/linux/ecosystem/apache2/php8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/apache2/php8.3/Makefile b/linux/ecosystem/apache2/php8.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/apache2/php8.3/Makefile +++ b/linux/ecosystem/apache2/php8.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/apache2/php8.3/kaniko-build.py b/linux/ecosystem/apache2/php8.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/apache2/php8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/apache2/php8.3/requirements.txt b/linux/ecosystem/apache2/php8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/apache2/php8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/latest/Makefile b/linux/ecosystem/atlassian/bitbucket/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/bitbucket/latest/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt b/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.11.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.11.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.11.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.9.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile b/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile b/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile b/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile b/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile b/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile b/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile b/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/latest/Makefile b/linux/ecosystem/atlassian/confluence/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/latest/Makefile +++ b/linux/ecosystem/atlassian/confluence/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/confluence/latest/kaniko-build.py b/linux/ecosystem/atlassian/confluence/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/latest/requirements.txt b/linux/ecosystem/atlassian/confluence/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/templates/5/Makefile b/linux/ecosystem/atlassian/confluence/templates/5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/templates/5/Makefile +++ b/linux/ecosystem/atlassian/confluence/templates/5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt b/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/templates/6/Makefile b/linux/ecosystem/atlassian/confluence/templates/6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/confluence/templates/6/Makefile +++ b/linux/ecosystem/atlassian/confluence/templates/6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py b/linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt b/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile b/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile +++ b/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crowd/5/5.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt b/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crowd/latest/Makefile b/linux/ecosystem/atlassian/crowd/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/crowd/latest/Makefile +++ b/linux/ecosystem/atlassian/crowd/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/crowd/latest/kaniko-build.py b/linux/ecosystem/atlassian/crowd/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crowd/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crowd/latest/requirements.txt b/linux/ecosystem/atlassian/crowd/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crowd/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5.a/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5a/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/crucible/templates/1/Makefile b/linux/ecosystem/atlassian/crucible/templates/1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/crucible/templates/1/Makefile +++ b/linux/ecosystem/atlassian/crucible/templates/1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt b/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/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 new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.0.1a/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.2.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5a/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/fisheye/templates/1/Makefile b/linux/ecosystem/atlassian/fisheye/templates/1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/fisheye/templates/1/Makefile +++ b/linux/ecosystem/atlassian/fisheye/templates/1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt b/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/4/4.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.0/Makefile b/linux/ecosystem/atlassian/jira/5/5.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/5/5.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.0/Makefile b/linux/ecosystem/atlassian/jira/6/6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/6/6.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.11.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.11.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.11.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.12.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.12.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.0.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.0.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.11.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.11.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.24/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.25/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.26/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.27/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.14.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.14.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.15.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.15.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.16.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.16.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.16.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.17.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.17.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.18.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.18.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.19.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.19.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.23/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.24/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.25/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.26/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.27/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.28/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.29/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.30/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.21.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.21.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.0.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.1.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.1.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.10.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.10.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.10.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.2.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.2.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/latest/Makefile b/linux/ecosystem/atlassian/jira/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/atlassian/jira/latest/Makefile +++ b/linux/ecosystem/atlassian/jira/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/atlassian/jira/latest/kaniko-build.py b/linux/ecosystem/atlassian/jira/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/atlassian/jira/latest/requirements.txt b/linux/ecosystem/atlassian/jira/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/cassandra/3.11/Makefile b/linux/ecosystem/cassandra/3.11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/cassandra/3.11/Makefile +++ b/linux/ecosystem/cassandra/3.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/cassandra/3.11/kaniko-build.py b/linux/ecosystem/cassandra/3.11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/cassandra/3.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/cassandra/3.11/requirements.txt b/linux/ecosystem/cassandra/3.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/cassandra/3.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/electron-release-server/Makefile b/linux/ecosystem/electron-release-server/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/electron-release-server/Makefile +++ b/linux/ecosystem/electron-release-server/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/electron-release-server/kaniko-build.py b/linux/ecosystem/electron-release-server/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/electron-release-server/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/electron-release-server/requirements.txt b/linux/ecosystem/electron-release-server/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/electron-release-server/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv 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 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile b/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile +++ b/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py b/linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt b/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile b/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile +++ b/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py b/linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt b/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/latest/Makefile b/linux/ecosystem/gitlab/runner/latest/Makefile index 7d2cd9dd3..7f38688cc 100644 --- a/linux/ecosystem/gitlab/runner/latest/Makefile +++ b/linux/ecosystem/gitlab/runner/latest/Makefile @@ -6,9 +6,32 @@ app: # 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push #clean: diff --git a/linux/ecosystem/gitlab/runner/latest/kaniko-build.py b/linux/ecosystem/gitlab/runner/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/latest/requirements.txt b/linux/ecosystem/gitlab/runner/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node0.12/Makefile b/linux/ecosystem/gitlab/runner/node0.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node0.12/Makefile +++ b/linux/ecosystem/gitlab/runner/node0.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py b/linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node0.12/requirements.txt b/linux/ecosystem/gitlab/runner/node0.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node0.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node10/Makefile b/linux/ecosystem/gitlab/runner/node10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node10/Makefile +++ b/linux/ecosystem/gitlab/runner/node10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node10/kaniko-build.py b/linux/ecosystem/gitlab/runner/node10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node10/requirements.txt b/linux/ecosystem/gitlab/runner/node10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node11/Makefile b/linux/ecosystem/gitlab/runner/node11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node11/Makefile +++ b/linux/ecosystem/gitlab/runner/node11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node11/kaniko-build.py b/linux/ecosystem/gitlab/runner/node11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node11/requirements.txt b/linux/ecosystem/gitlab/runner/node11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node12/Makefile b/linux/ecosystem/gitlab/runner/node12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node12/Makefile +++ b/linux/ecosystem/gitlab/runner/node12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node12/kaniko-build.py b/linux/ecosystem/gitlab/runner/node12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node12/requirements.txt b/linux/ecosystem/gitlab/runner/node12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node13/Makefile b/linux/ecosystem/gitlab/runner/node13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node13/Makefile +++ b/linux/ecosystem/gitlab/runner/node13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node13/kaniko-build.py b/linux/ecosystem/gitlab/runner/node13/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node13/requirements.txt b/linux/ecosystem/gitlab/runner/node13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node14/Makefile b/linux/ecosystem/gitlab/runner/node14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node14/Makefile +++ b/linux/ecosystem/gitlab/runner/node14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node14/kaniko-build.py b/linux/ecosystem/gitlab/runner/node14/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node14/requirements.txt b/linux/ecosystem/gitlab/runner/node14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node15/Makefile b/linux/ecosystem/gitlab/runner/node15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node15/Makefile +++ b/linux/ecosystem/gitlab/runner/node15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node15/kaniko-build.py b/linux/ecosystem/gitlab/runner/node15/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node15/requirements.txt b/linux/ecosystem/gitlab/runner/node15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node16/Makefile b/linux/ecosystem/gitlab/runner/node16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node16/Makefile +++ b/linux/ecosystem/gitlab/runner/node16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node16/kaniko-build.py b/linux/ecosystem/gitlab/runner/node16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node16/requirements.txt b/linux/ecosystem/gitlab/runner/node16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node17/Makefile b/linux/ecosystem/gitlab/runner/node17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node17/Makefile +++ b/linux/ecosystem/gitlab/runner/node17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node17/kaniko-build.py b/linux/ecosystem/gitlab/runner/node17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node17/requirements.txt b/linux/ecosystem/gitlab/runner/node17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node18/Makefile b/linux/ecosystem/gitlab/runner/node18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node18/Makefile +++ b/linux/ecosystem/gitlab/runner/node18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node18/kaniko-build.py b/linux/ecosystem/gitlab/runner/node18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node18/requirements.txt b/linux/ecosystem/gitlab/runner/node18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node19/Makefile b/linux/ecosystem/gitlab/runner/node19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node19/Makefile +++ b/linux/ecosystem/gitlab/runner/node19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node19/kaniko-build.py b/linux/ecosystem/gitlab/runner/node19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node19/requirements.txt b/linux/ecosystem/gitlab/runner/node19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node20/Makefile b/linux/ecosystem/gitlab/runner/node20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node20/Makefile +++ b/linux/ecosystem/gitlab/runner/node20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node20/kaniko-build.py b/linux/ecosystem/gitlab/runner/node20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node20/requirements.txt b/linux/ecosystem/gitlab/runner/node20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node21/Makefile b/linux/ecosystem/gitlab/runner/node21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node21/Makefile +++ b/linux/ecosystem/gitlab/runner/node21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node21/kaniko-build.py b/linux/ecosystem/gitlab/runner/node21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node21/requirements.txt b/linux/ecosystem/gitlab/runner/node21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node22/Makefile b/linux/ecosystem/gitlab/runner/node22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node22/Makefile +++ b/linux/ecosystem/gitlab/runner/node22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node22/kaniko-build.py b/linux/ecosystem/gitlab/runner/node22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node22/requirements.txt b/linux/ecosystem/gitlab/runner/node22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node4/Makefile b/linux/ecosystem/gitlab/runner/node4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node4/Makefile +++ b/linux/ecosystem/gitlab/runner/node4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node4/kaniko-build.py b/linux/ecosystem/gitlab/runner/node4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node4/requirements.txt b/linux/ecosystem/gitlab/runner/node4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node5/Makefile b/linux/ecosystem/gitlab/runner/node5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node5/Makefile +++ b/linux/ecosystem/gitlab/runner/node5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node5/kaniko-build.py b/linux/ecosystem/gitlab/runner/node5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node5/requirements.txt b/linux/ecosystem/gitlab/runner/node5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node6/Makefile b/linux/ecosystem/gitlab/runner/node6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node6/Makefile +++ b/linux/ecosystem/gitlab/runner/node6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node6/kaniko-build.py b/linux/ecosystem/gitlab/runner/node6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node6/requirements.txt b/linux/ecosystem/gitlab/runner/node6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node7/Makefile b/linux/ecosystem/gitlab/runner/node7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node7/Makefile +++ b/linux/ecosystem/gitlab/runner/node7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node7/kaniko-build.py b/linux/ecosystem/gitlab/runner/node7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node7/requirements.txt b/linux/ecosystem/gitlab/runner/node7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node8/Makefile b/linux/ecosystem/gitlab/runner/node8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node8/Makefile +++ b/linux/ecosystem/gitlab/runner/node8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node8/kaniko-build.py b/linux/ecosystem/gitlab/runner/node8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node8/requirements.txt b/linux/ecosystem/gitlab/runner/node8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/node9/Makefile b/linux/ecosystem/gitlab/runner/node9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/node9/Makefile +++ b/linux/ecosystem/gitlab/runner/node9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/node9/kaniko-build.py b/linux/ecosystem/gitlab/runner/node9/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/node9/requirements.txt b/linux/ecosystem/gitlab/runner/node9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/node9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php7.2/Makefile b/linux/ecosystem/gitlab/runner/php7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php7.2/Makefile +++ b/linux/ecosystem/gitlab/runner/php7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py b/linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php7.2/requirements.txt b/linux/ecosystem/gitlab/runner/php7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php7.3/Makefile b/linux/ecosystem/gitlab/runner/php7.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php7.3/Makefile +++ b/linux/ecosystem/gitlab/runner/php7.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py b/linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php7.3/requirements.txt b/linux/ecosystem/gitlab/runner/php7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php7.4/Makefile b/linux/ecosystem/gitlab/runner/php7.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php7.4/Makefile +++ b/linux/ecosystem/gitlab/runner/php7.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py b/linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php7.4/requirements.txt b/linux/ecosystem/gitlab/runner/php7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php8.0/Makefile b/linux/ecosystem/gitlab/runner/php8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php8.0/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php8.0/requirements.txt b/linux/ecosystem/gitlab/runner/php8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php8.1/Makefile b/linux/ecosystem/gitlab/runner/php8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php8.1/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php8.1/requirements.txt b/linux/ecosystem/gitlab/runner/php8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php8.2/Makefile b/linux/ecosystem/gitlab/runner/php8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php8.2/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php8.2/requirements.txt b/linux/ecosystem/gitlab/runner/php8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/php8.3/Makefile b/linux/ecosystem/gitlab/runner/php8.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/php8.3/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/php8.3/requirements.txt b/linux/ecosystem/gitlab/runner/php8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/php8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/gitlab/runner/steam-sdk/Makefile b/linux/ecosystem/gitlab/runner/steam-sdk/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/gitlab/runner/steam-sdk/Makefile +++ b/linux/ecosystem/gitlab/runner/steam-sdk/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py b/linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt b/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/monero/monerod/Makefile b/linux/ecosystem/monero/monerod/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/monero/monerod/Makefile +++ b/linux/ecosystem/monero/monerod/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/monero/monerod/kaniko-build.py b/linux/ecosystem/monero/monerod/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/monero/monerod/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/monero/monerod/requirements.txt b/linux/ecosystem/monero/monerod/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/monero/monerod/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/monero/p2pool/Makefile b/linux/ecosystem/monero/p2pool/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/monero/p2pool/Makefile +++ b/linux/ecosystem/monero/p2pool/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/monero/p2pool/kaniko-build.py b/linux/ecosystem/monero/p2pool/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/monero/p2pool/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/monero/p2pool/requirements.txt b/linux/ecosystem/monero/p2pool/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/monero/p2pool/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.14.2/main/Makefile b/linux/ecosystem/nginx/1.14.2/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.14.2/main/Makefile +++ b/linux/ecosystem/nginx/1.14.2/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.14.2/main/kaniko-build.py b/linux/ecosystem/nginx/1.14.2/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.14.2/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.14.2/main/requirements.txt b/linux/ecosystem/nginx/1.14.2/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.14.2/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.14.2/php/Makefile b/linux/ecosystem/nginx/1.14.2/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.14.2/php/Makefile +++ b/linux/ecosystem/nginx/1.14.2/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.14.2/php/kaniko-build.py b/linux/ecosystem/nginx/1.14.2/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.14.2/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.14.2/php/requirements.txt b/linux/ecosystem/nginx/1.14.2/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.14.2/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.14.2/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.15.12/main/Makefile b/linux/ecosystem/nginx/1.15.12/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.15.12/main/Makefile +++ b/linux/ecosystem/nginx/1.15.12/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.15.12/main/kaniko-build.py b/linux/ecosystem/nginx/1.15.12/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.15.12/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.15.12/main/requirements.txt b/linux/ecosystem/nginx/1.15.12/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.15.12/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.15.12/php/Makefile b/linux/ecosystem/nginx/1.15.12/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.15.12/php/Makefile +++ b/linux/ecosystem/nginx/1.15.12/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.15.12/php/kaniko-build.py b/linux/ecosystem/nginx/1.15.12/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.15.12/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.15.12/php/requirements.txt b/linux/ecosystem/nginx/1.15.12/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.15.12/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.15.12/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.16.1/main/Makefile b/linux/ecosystem/nginx/1.16.1/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.16.1/main/Makefile +++ b/linux/ecosystem/nginx/1.16.1/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.16.1/main/kaniko-build.py b/linux/ecosystem/nginx/1.16.1/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.16.1/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.16.1/main/requirements.txt b/linux/ecosystem/nginx/1.16.1/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.16.1/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.16.1/php/Makefile b/linux/ecosystem/nginx/1.16.1/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.16.1/php/Makefile +++ b/linux/ecosystem/nginx/1.16.1/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.16.1/php/kaniko-build.py b/linux/ecosystem/nginx/1.16.1/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.16.1/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.16.1/php/requirements.txt b/linux/ecosystem/nginx/1.16.1/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.16.1/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.16.1/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.17.10/main/Makefile b/linux/ecosystem/nginx/1.17.10/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.17.10/main/Makefile +++ b/linux/ecosystem/nginx/1.17.10/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.17.10/main/kaniko-build.py b/linux/ecosystem/nginx/1.17.10/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.17.10/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.17.10/main/requirements.txt b/linux/ecosystem/nginx/1.17.10/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.17.10/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.17.10/php/Makefile b/linux/ecosystem/nginx/1.17.10/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.17.10/php/Makefile +++ b/linux/ecosystem/nginx/1.17.10/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.17.10/php/kaniko-build.py b/linux/ecosystem/nginx/1.17.10/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.17.10/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.17.10/php/requirements.txt b/linux/ecosystem/nginx/1.17.10/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.17.10/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.17.10/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.18.0/main/Makefile b/linux/ecosystem/nginx/1.18.0/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.18.0/main/Makefile +++ b/linux/ecosystem/nginx/1.18.0/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.18.0/main/kaniko-build.py b/linux/ecosystem/nginx/1.18.0/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.18.0/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.18.0/main/requirements.txt b/linux/ecosystem/nginx/1.18.0/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.18.0/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.18.0/php/Makefile b/linux/ecosystem/nginx/1.18.0/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.18.0/php/Makefile +++ b/linux/ecosystem/nginx/1.18.0/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.18.0/php/kaniko-build.py b/linux/ecosystem/nginx/1.18.0/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.18.0/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.18.0/php/requirements.txt b/linux/ecosystem/nginx/1.18.0/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.18.0/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.18.0/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.19.10/main/Makefile b/linux/ecosystem/nginx/1.19.10/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.19.10/main/Makefile +++ b/linux/ecosystem/nginx/1.19.10/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.19.10/main/kaniko-build.py b/linux/ecosystem/nginx/1.19.10/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.19.10/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.19.10/main/requirements.txt b/linux/ecosystem/nginx/1.19.10/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.19.10/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.19.10/php/Makefile b/linux/ecosystem/nginx/1.19.10/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.19.10/php/Makefile +++ b/linux/ecosystem/nginx/1.19.10/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.19.10/php/kaniko-build.py b/linux/ecosystem/nginx/1.19.10/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.19.10/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.19.10/php/requirements.txt b/linux/ecosystem/nginx/1.19.10/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.19.10/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.19.10/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.20.1/main/Makefile b/linux/ecosystem/nginx/1.20.1/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.20.1/main/Makefile +++ b/linux/ecosystem/nginx/1.20.1/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.20.1/main/kaniko-build.py b/linux/ecosystem/nginx/1.20.1/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.20.1/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.20.1/main/requirements.txt b/linux/ecosystem/nginx/1.20.1/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.20.1/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.20.1/php/Makefile b/linux/ecosystem/nginx/1.20.1/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.20.1/php/Makefile +++ b/linux/ecosystem/nginx/1.20.1/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.20.1/php/kaniko-build.py b/linux/ecosystem/nginx/1.20.1/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.20.1/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.20.1/php/requirements.txt b/linux/ecosystem/nginx/1.20.1/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.20.1/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.20.1/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.21.3/main/Makefile b/linux/ecosystem/nginx/1.21.3/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.21.3/main/Makefile +++ b/linux/ecosystem/nginx/1.21.3/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.21.3/main/kaniko-build.py b/linux/ecosystem/nginx/1.21.3/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.21.3/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.21.3/main/requirements.txt b/linux/ecosystem/nginx/1.21.3/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.21.3/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.21.3/php/Makefile b/linux/ecosystem/nginx/1.21.3/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.21.3/php/Makefile +++ b/linux/ecosystem/nginx/1.21.3/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.21.3/php/kaniko-build.py b/linux/ecosystem/nginx/1.21.3/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.21.3/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.21.3/php/requirements.txt b/linux/ecosystem/nginx/1.21.3/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.21.3/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.21.3/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.21.6/main/Makefile b/linux/ecosystem/nginx/1.21.6/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.21.6/main/Makefile +++ b/linux/ecosystem/nginx/1.21.6/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.21.6/main/kaniko-build.py b/linux/ecosystem/nginx/1.21.6/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.21.6/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.21.6/main/requirements.txt b/linux/ecosystem/nginx/1.21.6/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.21.6/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.21.6/php/Makefile b/linux/ecosystem/nginx/1.21.6/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.21.6/php/Makefile +++ b/linux/ecosystem/nginx/1.21.6/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/1.21.6/php/kaniko-build.py b/linux/ecosystem/nginx/1.21.6/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.21.6/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.21.6/php/requirements.txt b/linux/ecosystem/nginx/1.21.6/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.21.6/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/1.21.6/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/latest/mainline/main/Makefile b/linux/ecosystem/nginx/latest/mainline/main/Makefile index 16452d6c3..1ae9e91b2 100644 --- a/linux/ecosystem/nginx/latest/mainline/main/Makefile +++ b/linux/ecosystem/nginx/latest/mainline/main/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py b/linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/latest/mainline/main/requirements.txt b/linux/ecosystem/nginx/latest/mainline/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/latest/mainline/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/latest/mainline/php/Makefile b/linux/ecosystem/nginx/latest/mainline/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/latest/mainline/php/Makefile +++ b/linux/ecosystem/nginx/latest/mainline/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py b/linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/latest/mainline/php/requirements.txt b/linux/ecosystem/nginx/latest/mainline/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/latest/mainline/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/latest/quic/main/Makefile b/linux/ecosystem/nginx/latest/quic/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/latest/quic/main/Makefile +++ b/linux/ecosystem/nginx/latest/quic/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/latest/quic/main/kaniko-build.py b/linux/ecosystem/nginx/latest/quic/main/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/latest/quic/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/latest/quic/main/requirements.txt b/linux/ecosystem/nginx/latest/quic/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/latest/quic/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/latest/quic/php/Makefile b/linux/ecosystem/nginx/latest/quic/php/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/latest/quic/php/Makefile +++ b/linux/ecosystem/nginx/latest/quic/php/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/latest/quic/php/kaniko-build.py b/linux/ecosystem/nginx/latest/quic/php/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/latest/quic/php/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/latest/quic/php/requirements.txt b/linux/ecosystem/nginx/latest/quic/php/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/latest/quic/php/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile b/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/ninjam/latest/Makefile b/linux/ecosystem/ninjam/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/ninjam/latest/Makefile +++ b/linux/ecosystem/ninjam/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/ninjam/latest/kaniko-build.py b/linux/ecosystem/ninjam/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/ninjam/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/ninjam/latest/requirements.txt b/linux/ecosystem/ninjam/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/ninjam/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/current/Makefile b/linux/ecosystem/nodejs/current/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/current/Makefile +++ b/linux/ecosystem/nodejs/current/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/current/kaniko-build.py b/linux/ecosystem/nodejs/current/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/current/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/current/requirements.txt b/linux/ecosystem/nodejs/current/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/current/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/lts/Makefile b/linux/ecosystem/nodejs/lts/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/lts/Makefile +++ b/linux/ecosystem/nodejs/lts/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/lts/kaniko-build.py b/linux/ecosystem/nodejs/lts/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/lts/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/lts/requirements.txt b/linux/ecosystem/nodejs/lts/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/lts/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node0.12/Makefile b/linux/ecosystem/nodejs/node0.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node0.12/Makefile +++ b/linux/ecosystem/nodejs/node0.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node0.12/kaniko-build.py b/linux/ecosystem/nodejs/node0.12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node0.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node0.12/requirements.txt b/linux/ecosystem/nodejs/node0.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node0.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node10/Makefile b/linux/ecosystem/nodejs/node10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node10/Makefile +++ b/linux/ecosystem/nodejs/node10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node10/kaniko-build.py b/linux/ecosystem/nodejs/node10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node10/requirements.txt b/linux/ecosystem/nodejs/node10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node11/Makefile b/linux/ecosystem/nodejs/node11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node11/Makefile +++ b/linux/ecosystem/nodejs/node11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node11/kaniko-build.py b/linux/ecosystem/nodejs/node11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node11/requirements.txt b/linux/ecosystem/nodejs/node11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node12/Makefile b/linux/ecosystem/nodejs/node12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node12/Makefile +++ b/linux/ecosystem/nodejs/node12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node12/kaniko-build.py b/linux/ecosystem/nodejs/node12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node12/requirements.txt b/linux/ecosystem/nodejs/node12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node13/Makefile b/linux/ecosystem/nodejs/node13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node13/Makefile +++ b/linux/ecosystem/nodejs/node13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node13/kaniko-build.py b/linux/ecosystem/nodejs/node13/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node13/requirements.txt b/linux/ecosystem/nodejs/node13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node14/Makefile b/linux/ecosystem/nodejs/node14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node14/Makefile +++ b/linux/ecosystem/nodejs/node14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node14/kaniko-build.py b/linux/ecosystem/nodejs/node14/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node14/requirements.txt b/linux/ecosystem/nodejs/node14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node15/Makefile b/linux/ecosystem/nodejs/node15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node15/Makefile +++ b/linux/ecosystem/nodejs/node15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node15/kaniko-build.py b/linux/ecosystem/nodejs/node15/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node15/requirements.txt b/linux/ecosystem/nodejs/node15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node16/Makefile b/linux/ecosystem/nodejs/node16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node16/Makefile +++ b/linux/ecosystem/nodejs/node16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node16/kaniko-build.py b/linux/ecosystem/nodejs/node16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node16/requirements.txt b/linux/ecosystem/nodejs/node16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node17/Makefile b/linux/ecosystem/nodejs/node17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node17/Makefile +++ b/linux/ecosystem/nodejs/node17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node17/kaniko-build.py b/linux/ecosystem/nodejs/node17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node17/requirements.txt b/linux/ecosystem/nodejs/node17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node18/Makefile b/linux/ecosystem/nodejs/node18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node18/Makefile +++ b/linux/ecosystem/nodejs/node18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node18/kaniko-build.py b/linux/ecosystem/nodejs/node18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node18/requirements.txt b/linux/ecosystem/nodejs/node18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node19/Makefile b/linux/ecosystem/nodejs/node19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node19/Makefile +++ b/linux/ecosystem/nodejs/node19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node19/kaniko-build.py b/linux/ecosystem/nodejs/node19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node19/requirements.txt b/linux/ecosystem/nodejs/node19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node20/Makefile b/linux/ecosystem/nodejs/node20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node20/Makefile +++ b/linux/ecosystem/nodejs/node20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node20/kaniko-build.py b/linux/ecosystem/nodejs/node20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node20/requirements.txt b/linux/ecosystem/nodejs/node20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node21/Makefile b/linux/ecosystem/nodejs/node21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node21/Makefile +++ b/linux/ecosystem/nodejs/node21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node21/kaniko-build.py b/linux/ecosystem/nodejs/node21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node21/requirements.txt b/linux/ecosystem/nodejs/node21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node22/Makefile b/linux/ecosystem/nodejs/node22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node22/Makefile +++ b/linux/ecosystem/nodejs/node22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node22/kaniko-build.py b/linux/ecosystem/nodejs/node22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node22/requirements.txt b/linux/ecosystem/nodejs/node22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node4/Makefile b/linux/ecosystem/nodejs/node4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node4/Makefile +++ b/linux/ecosystem/nodejs/node4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node4/kaniko-build.py b/linux/ecosystem/nodejs/node4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node4/requirements.txt b/linux/ecosystem/nodejs/node4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node5/Makefile b/linux/ecosystem/nodejs/node5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node5/Makefile +++ b/linux/ecosystem/nodejs/node5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node5/kaniko-build.py b/linux/ecosystem/nodejs/node5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node5/requirements.txt b/linux/ecosystem/nodejs/node5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node6/Makefile b/linux/ecosystem/nodejs/node6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node6/Makefile +++ b/linux/ecosystem/nodejs/node6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node6/kaniko-build.py b/linux/ecosystem/nodejs/node6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node6/requirements.txt b/linux/ecosystem/nodejs/node6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node7/Makefile b/linux/ecosystem/nodejs/node7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node7/Makefile +++ b/linux/ecosystem/nodejs/node7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node7/kaniko-build.py b/linux/ecosystem/nodejs/node7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node7/requirements.txt b/linux/ecosystem/nodejs/node7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node8/Makefile b/linux/ecosystem/nodejs/node8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node8/Makefile +++ b/linux/ecosystem/nodejs/node8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node8/kaniko-build.py b/linux/ecosystem/nodejs/node8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node8/requirements.txt b/linux/ecosystem/nodejs/node8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/nodejs/node9/Makefile b/linux/ecosystem/nodejs/node9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/nodejs/node9/Makefile +++ b/linux/ecosystem/nodejs/node9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/nodejs/node9/kaniko-build.py b/linux/ecosystem/nodejs/node9/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/nodejs/node9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/nodejs/node9/requirements.txt b/linux/ecosystem/nodejs/node9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/nodejs/node9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/opentracker/Makefile b/linux/ecosystem/opentracker/Makefile index a15587318..0c6ec12c1 100644 --- a/linux/ecosystem/opentracker/Makefile +++ b/linux/ecosystem/opentracker/Makefile @@ -9,6 +9,9 @@ build: docker-compose build --compress --no-cache --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/opentracker/kaniko-build.py b/linux/ecosystem/opentracker/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/opentracker/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/opentracker/requirements.txt b/linux/ecosystem/opentracker/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/opentracker/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r16.2/Makefile b/linux/ecosystem/perforce/base/r16.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r16.2/Makefile +++ b/linux/ecosystem/perforce/base/r16.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r16.2/kaniko-build.py b/linux/ecosystem/perforce/base/r16.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r16.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r16.2/requirements.txt b/linux/ecosystem/perforce/base/r16.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r16.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r17.1/Makefile b/linux/ecosystem/perforce/base/r17.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r17.1/Makefile +++ b/linux/ecosystem/perforce/base/r17.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r17.1/kaniko-build.py b/linux/ecosystem/perforce/base/r17.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r17.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r17.1/requirements.txt b/linux/ecosystem/perforce/base/r17.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r17.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r17.2/Makefile b/linux/ecosystem/perforce/base/r17.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r17.2/Makefile +++ b/linux/ecosystem/perforce/base/r17.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r17.2/kaniko-build.py b/linux/ecosystem/perforce/base/r17.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r17.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r17.2/requirements.txt b/linux/ecosystem/perforce/base/r17.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r17.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r18.1/Makefile b/linux/ecosystem/perforce/base/r18.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r18.1/Makefile +++ b/linux/ecosystem/perforce/base/r18.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r18.1/kaniko-build.py b/linux/ecosystem/perforce/base/r18.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r18.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r18.1/requirements.txt b/linux/ecosystem/perforce/base/r18.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r18.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r18.2/Makefile b/linux/ecosystem/perforce/base/r18.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r18.2/Makefile +++ b/linux/ecosystem/perforce/base/r18.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r18.2/kaniko-build.py b/linux/ecosystem/perforce/base/r18.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r18.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r18.2/requirements.txt b/linux/ecosystem/perforce/base/r18.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r18.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r19.1/Makefile b/linux/ecosystem/perforce/base/r19.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r19.1/Makefile +++ b/linux/ecosystem/perforce/base/r19.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r19.1/kaniko-build.py b/linux/ecosystem/perforce/base/r19.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r19.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r19.1/requirements.txt b/linux/ecosystem/perforce/base/r19.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r19.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r19.2/Makefile b/linux/ecosystem/perforce/base/r19.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r19.2/Makefile +++ b/linux/ecosystem/perforce/base/r19.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r19.2/kaniko-build.py b/linux/ecosystem/perforce/base/r19.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r19.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r19.2/requirements.txt b/linux/ecosystem/perforce/base/r19.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r19.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r20.1/Makefile b/linux/ecosystem/perforce/base/r20.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r20.1/Makefile +++ b/linux/ecosystem/perforce/base/r20.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r20.1/kaniko-build.py b/linux/ecosystem/perforce/base/r20.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r20.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r20.1/requirements.txt b/linux/ecosystem/perforce/base/r20.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r20.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r20.2/Makefile b/linux/ecosystem/perforce/base/r20.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r20.2/Makefile +++ b/linux/ecosystem/perforce/base/r20.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r20.2/kaniko-build.py b/linux/ecosystem/perforce/base/r20.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r20.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r20.2/requirements.txt b/linux/ecosystem/perforce/base/r20.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r20.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r21.1/Makefile b/linux/ecosystem/perforce/base/r21.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r21.1/Makefile +++ b/linux/ecosystem/perforce/base/r21.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r21.1/kaniko-build.py b/linux/ecosystem/perforce/base/r21.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r21.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r21.1/requirements.txt b/linux/ecosystem/perforce/base/r21.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r21.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r21.2/Makefile b/linux/ecosystem/perforce/base/r21.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r21.2/Makefile +++ b/linux/ecosystem/perforce/base/r21.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r21.2/kaniko-build.py b/linux/ecosystem/perforce/base/r21.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r21.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r21.2/requirements.txt b/linux/ecosystem/perforce/base/r21.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r21.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r22.1/Makefile b/linux/ecosystem/perforce/base/r22.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r22.1/Makefile +++ b/linux/ecosystem/perforce/base/r22.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r22.1/kaniko-build.py b/linux/ecosystem/perforce/base/r22.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r22.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r22.1/requirements.txt b/linux/ecosystem/perforce/base/r22.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r22.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r23.1/Makefile b/linux/ecosystem/perforce/base/r23.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r23.1/Makefile +++ b/linux/ecosystem/perforce/base/r23.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r23.1/kaniko-build.py b/linux/ecosystem/perforce/base/r23.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r23.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r23.1/requirements.txt b/linux/ecosystem/perforce/base/r23.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r23.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/base/r23.2/Makefile b/linux/ecosystem/perforce/base/r23.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/base/r23.2/Makefile +++ b/linux/ecosystem/perforce/base/r23.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/base/r23.2/kaniko-build.py b/linux/ecosystem/perforce/base/r23.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/base/r23.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/base/r23.2/requirements.txt b/linux/ecosystem/perforce/base/r23.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/base/r23.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r16.2/Makefile b/linux/ecosystem/perforce/p4p/r16.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r16.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r16.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r16.2/requirements.txt b/linux/ecosystem/perforce/p4p/r16.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r16.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r17.1/Makefile b/linux/ecosystem/perforce/p4p/r17.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r17.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r17.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r17.1/requirements.txt b/linux/ecosystem/perforce/p4p/r17.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r17.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r17.2/Makefile b/linux/ecosystem/perforce/p4p/r17.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r17.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r17.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r17.2/requirements.txt b/linux/ecosystem/perforce/p4p/r17.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r17.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r18.1/Makefile b/linux/ecosystem/perforce/p4p/r18.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r18.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r18.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r18.1/requirements.txt b/linux/ecosystem/perforce/p4p/r18.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r18.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r18.2/Makefile b/linux/ecosystem/perforce/p4p/r18.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r18.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r18.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r18.2/requirements.txt b/linux/ecosystem/perforce/p4p/r18.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r18.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r19.1/Makefile b/linux/ecosystem/perforce/p4p/r19.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r19.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r19.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r19.1/requirements.txt b/linux/ecosystem/perforce/p4p/r19.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r19.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r19.2/Makefile b/linux/ecosystem/perforce/p4p/r19.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r19.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r19.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r19.2/requirements.txt b/linux/ecosystem/perforce/p4p/r19.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r19.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r20.1/Makefile b/linux/ecosystem/perforce/p4p/r20.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r20.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r20.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r20.1/requirements.txt b/linux/ecosystem/perforce/p4p/r20.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r20.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r20.2/Makefile b/linux/ecosystem/perforce/p4p/r20.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r20.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r20.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r20.2/requirements.txt b/linux/ecosystem/perforce/p4p/r20.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r20.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r21.1/Makefile b/linux/ecosystem/perforce/p4p/r21.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r21.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r21.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r21.1/requirements.txt b/linux/ecosystem/perforce/p4p/r21.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r21.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r21.2/Makefile b/linux/ecosystem/perforce/p4p/r21.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r21.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r21.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r21.2/requirements.txt b/linux/ecosystem/perforce/p4p/r21.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r21.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r22.1/Makefile b/linux/ecosystem/perforce/p4p/r22.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r22.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r22.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r22.1/requirements.txt b/linux/ecosystem/perforce/p4p/r22.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r22.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r23.1/Makefile b/linux/ecosystem/perforce/p4p/r23.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r23.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r23.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r23.1/requirements.txt b/linux/ecosystem/perforce/p4p/r23.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r23.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/perforce/p4p/r23.2/Makefile b/linux/ecosystem/perforce/p4p/r23.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/perforce/p4p/r23.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r23.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/perforce/p4p/r23.2/requirements.txt b/linux/ecosystem/perforce/p4p/r23.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/perforce/p4p/r23.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php5.5/Makefile b/linux/ecosystem/php/php5.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php5.5/Makefile +++ b/linux/ecosystem/php/php5.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php5.5/kaniko-build.py b/linux/ecosystem/php/php5.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php5.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php5.5/requirements.txt b/linux/ecosystem/php/php5.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php5.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php7.0/Makefile b/linux/ecosystem/php/php7.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php7.0/Makefile +++ b/linux/ecosystem/php/php7.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php7.0/kaniko-build.py b/linux/ecosystem/php/php7.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php7.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php7.0/requirements.txt b/linux/ecosystem/php/php7.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php7.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php7.1/Makefile b/linux/ecosystem/php/php7.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php7.1/Makefile +++ b/linux/ecosystem/php/php7.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php7.1/kaniko-build.py b/linux/ecosystem/php/php7.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php7.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php7.1/requirements.txt b/linux/ecosystem/php/php7.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php7.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php7.2/Makefile b/linux/ecosystem/php/php7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php7.2/Makefile +++ b/linux/ecosystem/php/php7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php7.2/kaniko-build.py b/linux/ecosystem/php/php7.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php7.2/requirements.txt b/linux/ecosystem/php/php7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php7.3/Makefile b/linux/ecosystem/php/php7.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php7.3/Makefile +++ b/linux/ecosystem/php/php7.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php7.3/kaniko-build.py b/linux/ecosystem/php/php7.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php7.3/requirements.txt b/linux/ecosystem/php/php7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php7.4/Makefile b/linux/ecosystem/php/php7.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php7.4/Makefile +++ b/linux/ecosystem/php/php7.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php7.4/kaniko-build.py b/linux/ecosystem/php/php7.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php7.4/requirements.txt b/linux/ecosystem/php/php7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php8.0/Makefile b/linux/ecosystem/php/php8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php8.0/Makefile +++ b/linux/ecosystem/php/php8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php8.0/kaniko-build.py b/linux/ecosystem/php/php8.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php8.0/requirements.txt b/linux/ecosystem/php/php8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php8.1/Makefile b/linux/ecosystem/php/php8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php8.1/Makefile +++ b/linux/ecosystem/php/php8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php8.1/kaniko-build.py b/linux/ecosystem/php/php8.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php8.1/requirements.txt b/linux/ecosystem/php/php8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php8.2/Makefile b/linux/ecosystem/php/php8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php8.2/Makefile +++ b/linux/ecosystem/php/php8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php8.2/kaniko-build.py b/linux/ecosystem/php/php8.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php8.2/requirements.txt b/linux/ecosystem/php/php8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/php/php8.3/Makefile b/linux/ecosystem/php/php8.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/php/php8.3/Makefile +++ b/linux/ecosystem/php/php8.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/php/php8.3/kaniko-build.py b/linux/ecosystem/php/php8.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/php/php8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/php/php8.3/requirements.txt b/linux/ecosystem/php/php8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/php/php8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/10/Makefile b/linux/ecosystem/postgres/10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/10/Makefile +++ b/linux/ecosystem/postgres/10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/10/kaniko-build.py b/linux/ecosystem/postgres/10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/10/requirements.txt b/linux/ecosystem/postgres/10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/11/Makefile b/linux/ecosystem/postgres/11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/11/Makefile +++ b/linux/ecosystem/postgres/11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/11/kaniko-build.py b/linux/ecosystem/postgres/11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/11/requirements.txt b/linux/ecosystem/postgres/11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/12/Makefile b/linux/ecosystem/postgres/12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/12/Makefile +++ b/linux/ecosystem/postgres/12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/12/kaniko-build.py b/linux/ecosystem/postgres/12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/12/requirements.txt b/linux/ecosystem/postgres/12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/13/Makefile b/linux/ecosystem/postgres/13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/13/Makefile +++ b/linux/ecosystem/postgres/13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/13/kaniko-build.py b/linux/ecosystem/postgres/13/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/13/requirements.txt b/linux/ecosystem/postgres/13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/14/Makefile b/linux/ecosystem/postgres/14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/14/Makefile +++ b/linux/ecosystem/postgres/14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/14/kaniko-build.py b/linux/ecosystem/postgres/14/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/14/requirements.txt b/linux/ecosystem/postgres/14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/15/Makefile b/linux/ecosystem/postgres/15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/15/Makefile +++ b/linux/ecosystem/postgres/15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/15/kaniko-build.py b/linux/ecosystem/postgres/15/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/15/requirements.txt b/linux/ecosystem/postgres/15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/16/Makefile b/linux/ecosystem/postgres/16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/16/Makefile +++ b/linux/ecosystem/postgres/16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/16/kaniko-build.py b/linux/ecosystem/postgres/16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/16/requirements.txt b/linux/ecosystem/postgres/16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/8.2/Makefile b/linux/ecosystem/postgres/8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/8.2/Makefile +++ b/linux/ecosystem/postgres/8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/8.2/kaniko-build.py b/linux/ecosystem/postgres/8.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/8.2/requirements.txt b/linux/ecosystem/postgres/8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/8.3/Makefile b/linux/ecosystem/postgres/8.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/8.3/Makefile +++ b/linux/ecosystem/postgres/8.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/8.3/kaniko-build.py b/linux/ecosystem/postgres/8.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/8.3/requirements.txt b/linux/ecosystem/postgres/8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/8.4/Makefile b/linux/ecosystem/postgres/8.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/8.4/Makefile +++ b/linux/ecosystem/postgres/8.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/8.4/kaniko-build.py b/linux/ecosystem/postgres/8.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/8.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/8.4/requirements.txt b/linux/ecosystem/postgres/8.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/8.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.0/Makefile b/linux/ecosystem/postgres/9.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.0/Makefile +++ b/linux/ecosystem/postgres/9.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.0/kaniko-build.py b/linux/ecosystem/postgres/9.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.0/requirements.txt b/linux/ecosystem/postgres/9.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.1/Makefile b/linux/ecosystem/postgres/9.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.1/Makefile +++ b/linux/ecosystem/postgres/9.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.1/kaniko-build.py b/linux/ecosystem/postgres/9.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.1/requirements.txt b/linux/ecosystem/postgres/9.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.2/Makefile b/linux/ecosystem/postgres/9.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.2/Makefile +++ b/linux/ecosystem/postgres/9.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.2/kaniko-build.py b/linux/ecosystem/postgres/9.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.2/requirements.txt b/linux/ecosystem/postgres/9.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.3/Makefile b/linux/ecosystem/postgres/9.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.3/Makefile +++ b/linux/ecosystem/postgres/9.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.3/kaniko-build.py b/linux/ecosystem/postgres/9.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.3/requirements.txt b/linux/ecosystem/postgres/9.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.4/Makefile b/linux/ecosystem/postgres/9.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.4/Makefile +++ b/linux/ecosystem/postgres/9.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.4/kaniko-build.py b/linux/ecosystem/postgres/9.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.4/requirements.txt b/linux/ecosystem/postgres/9.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.5/Makefile b/linux/ecosystem/postgres/9.5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.5/Makefile +++ b/linux/ecosystem/postgres/9.5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.5/kaniko-build.py b/linux/ecosystem/postgres/9.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.5/requirements.txt b/linux/ecosystem/postgres/9.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/9.6/Makefile b/linux/ecosystem/postgres/9.6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/9.6/Makefile +++ b/linux/ecosystem/postgres/9.6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/9.6/kaniko-build.py b/linux/ecosystem/postgres/9.6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/9.6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/9.6/requirements.txt b/linux/ecosystem/postgres/9.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/9.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/postgres/latest/Makefile b/linux/ecosystem/postgres/latest/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/postgres/latest/Makefile +++ b/linux/ecosystem/postgres/latest/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/postgres/latest/kaniko-build.py b/linux/ecosystem/postgres/latest/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/postgres/latest/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/postgres/latest/requirements.txt b/linux/ecosystem/postgres/latest/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/postgres/latest/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.4.0/Makefile b/linux/ecosystem/qbittorrent/4.4.0/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.4.0/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.0/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.4.0/requirements.txt b/linux/ecosystem/qbittorrent/4.4.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.4.1/Makefile b/linux/ecosystem/qbittorrent/4.4.1/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.4.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.1/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.4.1/requirements.txt b/linux/ecosystem/qbittorrent/4.4.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.4.2/Makefile b/linux/ecosystem/qbittorrent/4.4.2/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.4.2/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.2/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.4.2/requirements.txt b/linux/ecosystem/qbittorrent/4.4.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.4.3.1/Makefile b/linux/ecosystem/qbittorrent/4.4.3.1/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.4.3.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.3.1/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt b/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.4.4/Makefile b/linux/ecosystem/qbittorrent/4.4.4/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.4.4/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.4/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.4.4/requirements.txt b/linux/ecosystem/qbittorrent/4.4.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.4.5/Makefile b/linux/ecosystem/qbittorrent/4.4.5/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.4.5/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.5/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.4.5/requirements.txt b/linux/ecosystem/qbittorrent/4.4.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.4.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.5.0/Makefile b/linux/ecosystem/qbittorrent/4.5.0/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.5.0/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.0/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.5.0/requirements.txt b/linux/ecosystem/qbittorrent/4.5.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.5.1/Makefile b/linux/ecosystem/qbittorrent/4.5.1/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.5.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.1/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.5.1/requirements.txt b/linux/ecosystem/qbittorrent/4.5.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.5.2/Makefile b/linux/ecosystem/qbittorrent/4.5.2/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.5.2/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.2/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.5.2/requirements.txt b/linux/ecosystem/qbittorrent/4.5.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.5.3/Makefile b/linux/ecosystem/qbittorrent/4.5.3/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.5.3/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.3/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.5.3/requirements.txt b/linux/ecosystem/qbittorrent/4.5.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.5.4/Makefile b/linux/ecosystem/qbittorrent/4.5.4/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.5.4/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.4/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.5.4/requirements.txt b/linux/ecosystem/qbittorrent/4.5.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.5.5/Makefile b/linux/ecosystem/qbittorrent/4.5.5/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.5.5/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.5/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.5.5/requirements.txt b/linux/ecosystem/qbittorrent/4.5.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.5.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.6.0/Makefile b/linux/ecosystem/qbittorrent/4.6.0/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.6.0/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.0/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.6.0/requirements.txt b/linux/ecosystem/qbittorrent/4.6.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.6.1/Makefile b/linux/ecosystem/qbittorrent/4.6.1/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.6.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.1/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.6.1/requirements.txt b/linux/ecosystem/qbittorrent/4.6.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.6.2/Makefile b/linux/ecosystem/qbittorrent/4.6.2/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.6.2/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.2/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.6.2/requirements.txt b/linux/ecosystem/qbittorrent/4.6.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.6.3/Makefile b/linux/ecosystem/qbittorrent/4.6.3/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.6.3/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.3/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.6.3/requirements.txt b/linux/ecosystem/qbittorrent/4.6.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/4.6.4/Makefile b/linux/ecosystem/qbittorrent/4.6.4/Makefile index 89eb81b08..95c5beb4d 100644 --- a/linux/ecosystem/qbittorrent/4.6.4/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.4/Makefile @@ -11,6 +11,9 @@ build: make qbt-libtorrent1 deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/4.6.4/requirements.txt b/linux/ecosystem/qbittorrent/4.6.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/4.6.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/qbittorrent/testing/Makefile b/linux/ecosystem/qbittorrent/testing/Makefile index bb1725b98..004b9e566 100644 --- a/linux/ecosystem/qbittorrent/testing/Makefile +++ b/linux/ecosystem/qbittorrent/testing/Makefile @@ -10,6 +10,9 @@ build: make qbt deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/qbittorrent/testing/kaniko-build.py b/linux/ecosystem/qbittorrent/testing/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/qbittorrent/testing/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/qbittorrent/testing/requirements.txt b/linux/ecosystem/qbittorrent/testing/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/qbittorrent/testing/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/retracker/Makefile b/linux/ecosystem/retracker/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/retracker/Makefile +++ b/linux/ecosystem/retracker/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/retracker/kaniko-build.py b/linux/ecosystem/retracker/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/retracker/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/retracker/requirements.txt b/linux/ecosystem/retracker/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/retracker/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile b/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile +++ b/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py b/linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt b/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile b/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile +++ b/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py b/linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt b/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node0.12/Makefile b/linux/ecosystem/teamcity/agent/node0.12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node0.12/Makefile +++ b/linux/ecosystem/teamcity/agent/node0.12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py b/linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node0.12/requirements.txt b/linux/ecosystem/teamcity/agent/node0.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node0.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node10/Makefile b/linux/ecosystem/teamcity/agent/node10/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node10/Makefile +++ b/linux/ecosystem/teamcity/agent/node10/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node10/kaniko-build.py b/linux/ecosystem/teamcity/agent/node10/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node10/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node10/requirements.txt b/linux/ecosystem/teamcity/agent/node10/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node10/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node11/Makefile b/linux/ecosystem/teamcity/agent/node11/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node11/Makefile +++ b/linux/ecosystem/teamcity/agent/node11/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node11/kaniko-build.py b/linux/ecosystem/teamcity/agent/node11/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node11/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node11/requirements.txt b/linux/ecosystem/teamcity/agent/node11/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node11/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node12/Makefile b/linux/ecosystem/teamcity/agent/node12/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node12/Makefile +++ b/linux/ecosystem/teamcity/agent/node12/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node12/kaniko-build.py b/linux/ecosystem/teamcity/agent/node12/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node12/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node12/requirements.txt b/linux/ecosystem/teamcity/agent/node12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node13/Makefile b/linux/ecosystem/teamcity/agent/node13/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node13/Makefile +++ b/linux/ecosystem/teamcity/agent/node13/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node13/kaniko-build.py b/linux/ecosystem/teamcity/agent/node13/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node13/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node13/requirements.txt b/linux/ecosystem/teamcity/agent/node13/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node13/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node14/Makefile b/linux/ecosystem/teamcity/agent/node14/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node14/Makefile +++ b/linux/ecosystem/teamcity/agent/node14/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node14/kaniko-build.py b/linux/ecosystem/teamcity/agent/node14/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node14/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node14/requirements.txt b/linux/ecosystem/teamcity/agent/node14/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node14/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node15/Makefile b/linux/ecosystem/teamcity/agent/node15/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node15/Makefile +++ b/linux/ecosystem/teamcity/agent/node15/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node15/kaniko-build.py b/linux/ecosystem/teamcity/agent/node15/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node15/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node15/requirements.txt b/linux/ecosystem/teamcity/agent/node15/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node15/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node16/Makefile b/linux/ecosystem/teamcity/agent/node16/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node16/Makefile +++ b/linux/ecosystem/teamcity/agent/node16/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node16/kaniko-build.py b/linux/ecosystem/teamcity/agent/node16/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node16/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node16/requirements.txt b/linux/ecosystem/teamcity/agent/node16/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node16/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node17/Makefile b/linux/ecosystem/teamcity/agent/node17/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node17/Makefile +++ b/linux/ecosystem/teamcity/agent/node17/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node17/kaniko-build.py b/linux/ecosystem/teamcity/agent/node17/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node17/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node17/requirements.txt b/linux/ecosystem/teamcity/agent/node17/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node17/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node18/Makefile b/linux/ecosystem/teamcity/agent/node18/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node18/Makefile +++ b/linux/ecosystem/teamcity/agent/node18/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node18/kaniko-build.py b/linux/ecosystem/teamcity/agent/node18/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node18/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node18/requirements.txt b/linux/ecosystem/teamcity/agent/node18/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node18/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node19/Makefile b/linux/ecosystem/teamcity/agent/node19/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node19/Makefile +++ b/linux/ecosystem/teamcity/agent/node19/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node19/kaniko-build.py b/linux/ecosystem/teamcity/agent/node19/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node19/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node19/requirements.txt b/linux/ecosystem/teamcity/agent/node19/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node19/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node20/Makefile b/linux/ecosystem/teamcity/agent/node20/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node20/Makefile +++ b/linux/ecosystem/teamcity/agent/node20/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node20/kaniko-build.py b/linux/ecosystem/teamcity/agent/node20/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node20/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node20/requirements.txt b/linux/ecosystem/teamcity/agent/node20/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node20/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node21/Makefile b/linux/ecosystem/teamcity/agent/node21/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node21/Makefile +++ b/linux/ecosystem/teamcity/agent/node21/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node21/kaniko-build.py b/linux/ecosystem/teamcity/agent/node21/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node21/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node21/requirements.txt b/linux/ecosystem/teamcity/agent/node21/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node21/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node22/Makefile b/linux/ecosystem/teamcity/agent/node22/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node22/Makefile +++ b/linux/ecosystem/teamcity/agent/node22/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node22/kaniko-build.py b/linux/ecosystem/teamcity/agent/node22/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node22/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node22/requirements.txt b/linux/ecosystem/teamcity/agent/node22/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node22/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node4/Makefile b/linux/ecosystem/teamcity/agent/node4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node4/Makefile +++ b/linux/ecosystem/teamcity/agent/node4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node4/kaniko-build.py b/linux/ecosystem/teamcity/agent/node4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node4/requirements.txt b/linux/ecosystem/teamcity/agent/node4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node5/Makefile b/linux/ecosystem/teamcity/agent/node5/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node5/Makefile +++ b/linux/ecosystem/teamcity/agent/node5/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node5/kaniko-build.py b/linux/ecosystem/teamcity/agent/node5/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node5/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node5/requirements.txt b/linux/ecosystem/teamcity/agent/node5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node6/Makefile b/linux/ecosystem/teamcity/agent/node6/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node6/Makefile +++ b/linux/ecosystem/teamcity/agent/node6/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node6/kaniko-build.py b/linux/ecosystem/teamcity/agent/node6/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node6/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node6/requirements.txt b/linux/ecosystem/teamcity/agent/node6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node7/Makefile b/linux/ecosystem/teamcity/agent/node7/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node7/Makefile +++ b/linux/ecosystem/teamcity/agent/node7/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node7/kaniko-build.py b/linux/ecosystem/teamcity/agent/node7/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node7/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node7/requirements.txt b/linux/ecosystem/teamcity/agent/node7/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node7/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node8/Makefile b/linux/ecosystem/teamcity/agent/node8/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node8/Makefile +++ b/linux/ecosystem/teamcity/agent/node8/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node8/kaniko-build.py b/linux/ecosystem/teamcity/agent/node8/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node8/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node8/requirements.txt b/linux/ecosystem/teamcity/agent/node8/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node8/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/node9/Makefile b/linux/ecosystem/teamcity/agent/node9/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/node9/Makefile +++ b/linux/ecosystem/teamcity/agent/node9/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/node9/kaniko-build.py b/linux/ecosystem/teamcity/agent/node9/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node9/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/node9/requirements.txt b/linux/ecosystem/teamcity/agent/node9/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/node9/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php7.2/Makefile b/linux/ecosystem/teamcity/agent/php7.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php7.2/Makefile +++ b/linux/ecosystem/teamcity/agent/php7.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py b/linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php7.2/requirements.txt b/linux/ecosystem/teamcity/agent/php7.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php7.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php7.3/Makefile b/linux/ecosystem/teamcity/agent/php7.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php7.3/Makefile +++ b/linux/ecosystem/teamcity/agent/php7.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py b/linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php7.3/requirements.txt b/linux/ecosystem/teamcity/agent/php7.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php7.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php7.4/Makefile b/linux/ecosystem/teamcity/agent/php7.4/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php7.4/Makefile +++ b/linux/ecosystem/teamcity/agent/php7.4/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py b/linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php7.4/requirements.txt b/linux/ecosystem/teamcity/agent/php7.4/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php7.4/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php8.0/Makefile b/linux/ecosystem/teamcity/agent/php8.0/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php8.0/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.0/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php8.0/requirements.txt b/linux/ecosystem/teamcity/agent/php8.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php8.1/Makefile b/linux/ecosystem/teamcity/agent/php8.1/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php8.1/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.1/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php8.1/requirements.txt b/linux/ecosystem/teamcity/agent/php8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php8.2/Makefile b/linux/ecosystem/teamcity/agent/php8.2/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php8.2/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.2/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php8.2/requirements.txt b/linux/ecosystem/teamcity/agent/php8.2/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.2/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/php8.3/Makefile b/linux/ecosystem/teamcity/agent/php8.3/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/php8.3/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.3/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/php8.3/requirements.txt b/linux/ecosystem/teamcity/agent/php8.3/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/php8.3/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/teamcity/agent/steam-sdk/Makefile b/linux/ecosystem/teamcity/agent/steam-sdk/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/teamcity/agent/steam-sdk/Makefile +++ b/linux/ecosystem/teamcity/agent/steam-sdk/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py b/linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt b/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile b/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile +++ b/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.4.1.3669/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt b/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile b/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile +++ b/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.4.1.3669/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt b/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.4.1.3669/main/Makefile b/linux/ecosystem/testrail/5.4.1.3669/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/main/Makefile +++ b/linux/ecosystem/testrail/5.4.1.3669/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.4.1.3669/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt b/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile b/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3727/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt b/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile b/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3727/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3727/main/Makefile b/linux/ecosystem/testrail/5.5.0.3727/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/main/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3727/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3727/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt b/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile b/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3731/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt b/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile b/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3731/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3731/main/Makefile b/linux/ecosystem/testrail/5.5.0.3731/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/main/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3731/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3731/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt b/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile b/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3735/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt b/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile b/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3735/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.0.3735/main/Makefile b/linux/ecosystem/testrail/5.5.0.3735/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/main/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3735/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3735/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt b/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile b/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.1.3746/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt b/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile b/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.1.3746/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.5.1.3746/main/Makefile b/linux/ecosystem/testrail/5.5.1.3746/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/main/Makefile +++ b/linux/ecosystem/testrail/5.5.1.3746/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.5.1.3746/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt b/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3853/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3853/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3853/main/Makefile b/linux/ecosystem/testrail/5.6.0.3853/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3853/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3853/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3856/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3856/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3856/main/Makefile b/linux/ecosystem/testrail/5.6.0.3856/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3856/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3856/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3861/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3861/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3861/main/Makefile b/linux/ecosystem/testrail/5.6.0.3861/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3861/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3861/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3862/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3862/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3862/main/Makefile b/linux/ecosystem/testrail/5.6.0.3862/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3862/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3862/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3865/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3865/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.6.0.3865/main/Makefile b/linux/ecosystem/testrail/5.6.0.3865/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3865/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3865/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile b/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3938/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt b/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile b/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3938/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3938/main/Makefile b/linux/ecosystem/testrail/5.7.0.3938/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/main/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3938/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3938/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt b/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile b/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3942/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt b/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile b/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3942/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3942/main/Makefile b/linux/ecosystem/testrail/5.7.0.3942/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/main/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3942/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3942/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt b/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile b/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3951/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt b/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile b/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3951/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.0.3951/main/Makefile b/linux/ecosystem/testrail/5.7.0.3951/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/main/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3951/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3951/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt b/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile b/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4026/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt b/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile b/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4026/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.1.4026/main/Makefile b/linux/ecosystem/testrail/5.7.1.4026/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/main/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4026/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4026/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt b/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile b/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4028/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt b/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile b/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4028/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/5.7.1.4028/main/Makefile b/linux/ecosystem/testrail/5.7.1.4028/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/main/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4028/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4028/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt b/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile b/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile +++ b/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.0.0.4140/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt b/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile b/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile +++ b/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.0.0.4140/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt b/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.0.0.4140/main/Makefile b/linux/ecosystem/testrail/6.0.0.4140/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/main/Makefile +++ b/linux/ecosystem/testrail/6.0.0.4140/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.0.0.4140/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt b/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile b/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile +++ b/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.0.1.4163/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt b/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile b/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile +++ b/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.0.1.4163/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt b/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.0.1.4163/main/Makefile b/linux/ecosystem/testrail/6.0.1.4163/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/main/Makefile +++ b/linux/ecosystem/testrail/6.0.1.4163/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.0.1.4163/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt b/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile b/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4367/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt b/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile b/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4367/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.0.4367/main/Makefile b/linux/ecosystem/testrail/6.1.0.4367/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/main/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4367/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4367/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt b/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile b/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4369/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt b/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile b/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4369/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.0.4369/main/Makefile b/linux/ecosystem/testrail/6.1.0.4369/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/main/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4369/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4369/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt b/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile b/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1020/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt b/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile b/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1020/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.1.1020/main/Makefile b/linux/ecosystem/testrail/6.1.1.1020/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/main/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1020/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1020/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt b/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile b/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1021/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt b/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile b/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1021/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.1.1.1021/main/Makefile b/linux/ecosystem/testrail/6.1.1.1021/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/main/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1021/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1021/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt b/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile b/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.0.1085/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt b/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile b/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.0.1085/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.0.1085/main/Makefile b/linux/ecosystem/testrail/6.2.0.1085/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/main/Makefile +++ b/linux/ecosystem/testrail/6.2.0.1085/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.0.1085/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt b/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile b/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1003/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt b/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile b/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1003/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.1.1003/main/Makefile b/linux/ecosystem/testrail/6.2.1.1003/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/main/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1003/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1003/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt b/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile b/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1005/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt b/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile b/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1005/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.1.1005/main/Makefile b/linux/ecosystem/testrail/6.2.1.1005/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/main/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1005/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1005/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt b/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile b/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.2.1107/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt b/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile b/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.2.1107/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.2.1107/main/Makefile b/linux/ecosystem/testrail/6.2.2.1107/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/main/Makefile +++ b/linux/ecosystem/testrail/6.2.2.1107/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.2.1107/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt b/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile b/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.3.1114/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt b/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile b/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.3.1114/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.2.3.1114/main/Makefile b/linux/ecosystem/testrail/6.2.3.1114/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/main/Makefile +++ b/linux/ecosystem/testrail/6.2.3.1114/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.2.3.1114/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt b/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile b/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile +++ b/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.0.1120/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt b/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile b/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile +++ b/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.0.1120/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt b/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.0.1120/main/Makefile b/linux/ecosystem/testrail/6.3.0.1120/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/main/Makefile +++ b/linux/ecosystem/testrail/6.3.0.1120/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.0.1120/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt b/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile b/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1004/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt b/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile b/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1004/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt b/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.1.1004/main/Makefile b/linux/ecosystem/testrail/6.3.1.1004/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/main/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1004/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1004/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt b/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile b/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1006/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt b/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile b/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1006/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt b/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.3.1.1006/main/Makefile b/linux/ecosystem/testrail/6.3.1.1006/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/main/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1006/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1006/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt b/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile b/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1284/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt b/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile b/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1284/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt b/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.4.0.1284/main/Makefile b/linux/ecosystem/testrail/6.4.0.1284/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/main/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1284/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1284/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt b/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile b/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1293/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt b/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile b/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1293/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt b/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.4.0.1293/main/Makefile b/linux/ecosystem/testrail/6.4.0.1293/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/main/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1293/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1293/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt b/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile b/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.0.1298/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt b/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile b/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.0.1298/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.0.1298/main/Makefile b/linux/ecosystem/testrail/6.5.0.1298/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/main/Makefile +++ b/linux/ecosystem/testrail/6.5.0.1298/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.0.1298/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt b/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile b/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.1.1002/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt b/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile b/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.1.1002/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.1.1002/main/Makefile b/linux/ecosystem/testrail/6.5.1.1002/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/main/Makefile +++ b/linux/ecosystem/testrail/6.5.1.1002/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.1.1002/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt b/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile b/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.3.1001/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt b/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile b/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.3.1001/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.3.1001/main/Makefile b/linux/ecosystem/testrail/6.5.3.1001/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/main/Makefile +++ b/linux/ecosystem/testrail/6.5.3.1001/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.3.1001/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt b/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile b/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1002/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt b/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile b/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1002/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.4.1002/main/Makefile b/linux/ecosystem/testrail/6.5.4.1002/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/main/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1002/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1002/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt b/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile b/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1007/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt b/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile b/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1007/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.4.1007/main/Makefile b/linux/ecosystem/testrail/6.5.4.1007/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/main/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1007/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1007/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt b/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile b/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.5.1009/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt b/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile b/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.5.1009/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.5.1009/main/Makefile b/linux/ecosystem/testrail/6.5.5.1009/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/main/Makefile +++ b/linux/ecosystem/testrail/6.5.5.1009/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.5.1009/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt b/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile b/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.6.1014/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt b/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile b/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.6.1014/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.6.1014/main/Makefile b/linux/ecosystem/testrail/6.5.6.1014/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/main/Makefile +++ b/linux/ecosystem/testrail/6.5.6.1014/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.6.1014/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt b/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile b/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.7.1000/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt b/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile b/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.7.1000/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.5.7.1000/main/Makefile b/linux/ecosystem/testrail/6.5.7.1000/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/main/Makefile +++ b/linux/ecosystem/testrail/6.5.7.1000/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.5.7.1000/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt b/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile b/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile +++ b/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.6.0.1156/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt b/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile b/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile +++ b/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.6.0.1156/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt b/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.6.0.1156/main/Makefile b/linux/ecosystem/testrail/6.6.0.1156/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/main/Makefile +++ b/linux/ecosystem/testrail/6.6.0.1156/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.6.0.1156/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt b/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile b/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile +++ b/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.6.1.1166/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt b/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile b/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile +++ b/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.6.1.1166/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt b/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.6.1.1166/main/Makefile b/linux/ecosystem/testrail/6.6.1.1166/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/main/Makefile +++ b/linux/ecosystem/testrail/6.6.1.1166/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.6.1.1166/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt b/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile b/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile +++ b/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.1.1020/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt b/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile b/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile +++ b/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.1.1020/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt b/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.1.1020/main/Makefile b/linux/ecosystem/testrail/6.7.1.1020/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/main/Makefile +++ b/linux/ecosystem/testrail/6.7.1.1020/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.1.1020/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt b/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile b/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1037/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt b/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile b/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1037/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt b/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.2.1037/main/Makefile b/linux/ecosystem/testrail/6.7.2.1037/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/main/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1037/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1037/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt b/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile b/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1043/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt b/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile b/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1043/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt b/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/6.7.2.1043/main/Makefile b/linux/ecosystem/testrail/6.7.2.1043/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/main/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1043/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1043/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt b/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile b/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.0.1057/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt b/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile b/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.0.1057/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.0.1057/main/Makefile b/linux/ecosystem/testrail/7.0.0.1057/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/main/Makefile +++ b/linux/ecosystem/testrail/7.0.0.1057/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.0.1057/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt b/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile b/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1002/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt b/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile b/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1002/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.1.1002/main/Makefile b/linux/ecosystem/testrail/7.0.1.1002/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/main/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1002/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1002/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt b/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile b/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1013/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt b/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile b/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1013/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.1.1013/main/Makefile b/linux/ecosystem/testrail/7.0.1.1013/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/main/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1013/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1013/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt b/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile b/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1014/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt b/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile b/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1014/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1014/main/Makefile b/linux/ecosystem/testrail/7.0.2.1014/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/main/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1014/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1014/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt b/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile b/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1015/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt b/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile b/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1015/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1015/main/Makefile b/linux/ecosystem/testrail/7.0.2.1015/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/main/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1015/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1015/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt b/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile b/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1016/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt b/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile b/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1016/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.0.2.1016/main/Makefile b/linux/ecosystem/testrail/7.0.2.1016/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/main/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1016/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1016/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt b/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile b/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8079/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt b/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile b/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8079/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt b/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8079/main/Makefile b/linux/ecosystem/testrail/7.4.1.8079/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/main/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8079/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8079/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt b/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile b/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8091/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt b/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile b/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8091/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt b/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8091/main/Makefile b/linux/ecosystem/testrail/7.4.1.8091/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/main/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8091/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8091/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt b/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile b/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8092/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt b/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile b/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8092/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt b/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.4.1.8092/main/Makefile b/linux/ecosystem/testrail/7.4.1.8092/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/main/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8092/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8092/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt b/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile b/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7010/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt b/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile b/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7010/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7010/main/Makefile b/linux/ecosystem/testrail/7.5.1.7010/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/main/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7010/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7010/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt b/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile b/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7012/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt b/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile b/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7012/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7012/main/Makefile b/linux/ecosystem/testrail/7.5.1.7012/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/main/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7012/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7012/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt b/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile b/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7013/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt b/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile b/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7013/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.1.7013/main/Makefile b/linux/ecosystem/testrail/7.5.1.7013/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/main/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7013/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7013/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt b/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile b/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.2.1002/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt b/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile b/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.2.1002/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.2.1002/main/Makefile b/linux/ecosystem/testrail/7.5.2.1002/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/main/Makefile +++ b/linux/ecosystem/testrail/7.5.2.1002/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.2.1002/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt b/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile b/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.3.1000/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt b/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile b/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.3.1000/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/7.5.3.1000/main/Makefile b/linux/ecosystem/testrail/7.5.3.1000/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/main/Makefile +++ b/linux/ecosystem/testrail/7.5.3.1000/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/7.5.3.1000/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt b/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile b/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile +++ b/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/8.0.0.1089/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt b/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile b/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile +++ b/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/8.0.0.1089/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt b/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/8.0.0.1089/main/Makefile b/linux/ecosystem/testrail/8.0.0.1089/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/main/Makefile +++ b/linux/ecosystem/testrail/8.0.0.1089/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/8.0.0.1089/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt b/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile b/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile +++ b/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/8.0.1.1029/ad/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt b/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile b/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile +++ b/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/8.0.1.1029/ldap/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt b/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/testrail/8.0.1.1029/main/Makefile b/linux/ecosystem/testrail/8.0.1.1029/main/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/main/Makefile +++ b/linux/ecosystem/testrail/8.0.1.1029/main/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: 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 new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/testrail/8.0.1.1029/main/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt b/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/torrserver/Makefile b/linux/ecosystem/torrserver/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/torrserver/Makefile +++ b/linux/ecosystem/torrserver/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/torrserver/kaniko-build.py b/linux/ecosystem/torrserver/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/torrserver/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/torrserver/requirements.txt b/linux/ecosystem/torrserver/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/torrserver/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/torrust-index/Makefile b/linux/ecosystem/torrust-index/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/torrust-index/Makefile +++ b/linux/ecosystem/torrust-index/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/torrust-index/kaniko-build.py b/linux/ecosystem/torrust-index/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/torrust-index/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/torrust-index/requirements.txt b/linux/ecosystem/torrust-index/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/torrust-index/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/torrust-tracker/Makefile b/linux/ecosystem/torrust-tracker/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/torrust-tracker/Makefile +++ b/linux/ecosystem/torrust-tracker/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/torrust-tracker/kaniko-build.py b/linux/ecosystem/torrust-tracker/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/torrust-tracker/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/torrust-tracker/requirements.txt b/linux/ecosystem/torrust-tracker/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/torrust-tracker/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/vk2discord/Makefile b/linux/ecosystem/vk2discord/Makefile index 9ef622aa9..e981a0d17 100644 --- a/linux/ecosystem/vk2discord/Makefile +++ b/linux/ecosystem/vk2discord/Makefile @@ -6,9 +6,32 @@ app: 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.0-debug --dry-run + +pip: + 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 + pip install -r requirements.txt + +build-compose: docker-compose build --compress --parallel --progress plain deploy: + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug + +deploy-compose: docker-compose push clean: diff --git a/linux/ecosystem/vk2discord/kaniko-build.py b/linux/ecosystem/vk2discord/kaniko-build.py new file mode 100644 index 000000000..e2034145c --- /dev/null +++ b/linux/ecosystem/vk2discord/kaniko-build.py @@ -0,0 +1,194 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections 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/linux/ecosystem/vk2discord/requirements.txt b/linux/ecosystem/vk2discord/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/vk2discord/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv