jdk19 for bookworm fix

jdk for bookworm fix
This commit is contained in:
STAM 2024-06-24 14:05:14 +03:00
parent 17f37c076a
commit 1e31bdbb06
No known key found for this signature in database
GPG Key ID: 711526C6938897F1
7 changed files with 449 additions and 0 deletions

View File

@ -406,6 +406,7 @@ ecosystem-debian-bullseye-images:
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19 && pwd && make build && make deploy
@ -420,7 +421,10 @@ ecosystem-debian-bookworm-images:
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20 && pwd && make build && make deploy
cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21 && pwd && make build && make deploy

View File

@ -0,0 +1,98 @@
FROM epicmorg/debian:bookworm
LABEL maintainer="EpicMorg DevTeam, developer@epicm.org"
ARG DEBIAN_FRONTEND=noninteractive
ARG K_JDK_MAJOR_VERSION=19
ARG K_JDK_FULL_VERSION=jdk-19.0.2
ARG K_JDK_VERSION=19.0.2
ARG K_JDK_BUILD_VERSION=7
ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries/releases/download/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION}/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz
ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz
ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION}
ENV PATH=$PATH:${JAVA_HOME}/bin
##################################################################
# installing java18
##################################################################
ADD ${K_JDK_URL} /tmp
RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \
java -version
##################################################################
# Additional settings
##################################################################
ENV MAVEN_VERSION=3.9.8
ENV MAVEN_LINK=https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.zip
ENV MAVEN_ROOT=/usr/local/maven
ENV MAVEN_PATH=${MAVEN_ROOT}/apache-maven-${MAVEN_VERSION}
ENV MAVEN_BIN=${MAVEN_PATH}/bin
ARG MAVEN_TEMP=/tmp/apache-maven-${MAVEN_VERSION}-bin.zip
ENV GRADLE_VERSION=8.8
ENV GRADLE_LINK=https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
ENV GRADLE_ROOT=/usr/local/gradle
ENV GRADLE_PATH=${GRADLE_ROOT}/gradle-${GRADLE_VERSION}
ENV GRADLE_BIN=${GRADLE_PATH}/bin
ARG GRADLE_TEMP=/tmp/gradle-${GRADLE_VERSION}-all.zip
ENV KTC_VERSION=2.0.0
ENV KTC_LINK=https://github.com/JetBrains/kotlin/releases/download/v${KTC_VERSION}/kotlin-compiler-${KTC_VERSION}.zip
ARG KTC_TEMP=/tmp/kotlin-compiler-${KTC_VERSION}.zip
ENV KTC_ROOT=/usr/local/kotlin
ENV KTC_PATH=${KTC_ROOT}/kotlinc
ENV KTC_BIN=${KTC_PATH}/bin
ENV KNPL_VERSION=${KTC_VERSION}
ENV KNPL_LINK=https://github.com/JetBrains/kotlin/releases/download/v${KNPL_VERSION}/kotlin-native-prebuilt-linux-x86_64-${KNPL_VERSION}.tar.gz
ARG KNPL_TEMP=/tmp/kotlin-native-prebuilt-linux-x86_64-${KNPL_VERSION}.tar.gz
ENV KNPL_ROOT=/usr/local/kotlin
ENV KNPL_PATH=${KNPL_ROOT}/kotlin-native-prebuilt-linux-x86_64-${KNPL_VERSION}
ENV KNPL_BIN=${KNPL_PATH}/bin
RUN mkdir -p ${MAVEN_PATH} ${KTC_PATH} ${KNPL_PATH} ${GRADLE_PATH}
ENV PATH=${PATH}:${MAVEN_BIN}:${GRADLE_BIN}:${KTC_BIN}:${KNPL_BIN}
##################################################################
# Maven
##################################################################
ENV MAVEN_HOME=${MAVEN_ROOT}
ENV M2_HOME=${MAVEN_ROOT}
ADD ${MAVEN_LINK} /tmp
RUN 7zz x ${MAVEN_TEMP} -o${MAVEN_ROOT}
RUN chmod +x -R ${MAVEN_BIN}
RUN mvn -v
##################################################################
# GRADLE
##################################################################
ADD ${GRADLE_LINK} /tmp
RUN 7zz x ${GRADLE_TEMP} -o${GRADLE_ROOT}
RUN chmod +x -R ${GRADLE_BIN}
RUN gradle -v
##################################################################
# kotlin-compiler
##################################################################
ADD ${KTC_LINK} /tmp
RUN 7zz x ${KTC_TEMP} -o${KTC_ROOT}
RUN chmod +x -R ${KTC_BIN}
RUN kotlin -version
##################################################################
# kotlin-native-prebuilt-linux
##################################################################
ADD ${KNPL_LINK} /tmp
RUN tar -xvzf ${KNPL_TEMP} --directory ${KTC_ROOT}
RUN chmod +x -R ${KNPL_BIN}
##################################################################
# cleanup
##################################################################
RUN echo "clean up" && \
apt-get clean -y && \
apt-get autoclean -y && \
rm -rfv /var/lib/apt/lists/* && \
rm -rfv /tmp/* && \
rm -rfv /var/cache/apt/archives/*.deb

View File

@ -0,0 +1,98 @@
FROM epicmorg/debian:bookworm-develop
LABEL maintainer="EpicMorg DevTeam, developer@epicm.org"
ARG DEBIAN_FRONTEND=noninteractive
ARG K_JDK_MAJOR_VERSION=19
ARG K_JDK_FULL_VERSION=jdk-19.0.2
ARG K_JDK_VERSION=19.0.2
ARG K_JDK_BUILD_VERSION=7
ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries/releases/download/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION}/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz
ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz
ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION}
ENV PATH=$PATH:${JAVA_HOME}/bin
##################################################################
# installing java18
##################################################################
ADD ${K_JDK_URL} /tmp
RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \
java -version
##################################################################
# Additional settings
##################################################################
ENV MAVEN_VERSION=3.9.8
ENV MAVEN_LINK=https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.zip
ENV MAVEN_ROOT=/usr/local/maven
ENV MAVEN_PATH=${MAVEN_ROOT}/apache-maven-${MAVEN_VERSION}
ENV MAVEN_BIN=${MAVEN_PATH}/bin
ARG MAVEN_TEMP=/tmp/apache-maven-${MAVEN_VERSION}-bin.zip
ENV GRADLE_VERSION=8.8
ENV GRADLE_LINK=https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
ENV GRADLE_ROOT=/usr/local/gradle
ENV GRADLE_PATH=${GRADLE_ROOT}/gradle-${GRADLE_VERSION}
ENV GRADLE_BIN=${GRADLE_PATH}/bin
ARG GRADLE_TEMP=/tmp/gradle-${GRADLE_VERSION}-all.zip
ENV KTC_VERSION=2.0.0
ENV KTC_LINK=https://github.com/JetBrains/kotlin/releases/download/v${KTC_VERSION}/kotlin-compiler-${KTC_VERSION}.zip
ARG KTC_TEMP=/tmp/kotlin-compiler-${KTC_VERSION}.zip
ENV KTC_ROOT=/usr/local/kotlin
ENV KTC_PATH=${KTC_ROOT}/kotlinc
ENV KTC_BIN=${KTC_PATH}/bin
ENV KNPL_VERSION=${KTC_VERSION}
ENV KNPL_LINK=https://github.com/JetBrains/kotlin/releases/download/v${KNPL_VERSION}/kotlin-native-prebuilt-linux-x86_64-${KNPL_VERSION}.tar.gz
ARG KNPL_TEMP=/tmp/kotlin-native-prebuilt-linux-x86_64-${KNPL_VERSION}.tar.gz
ENV KNPL_ROOT=/usr/local/kotlin
ENV KNPL_PATH=${KNPL_ROOT}/kotlin-native-prebuilt-linux-x86_64-${KNPL_VERSION}
ENV KNPL_BIN=${KNPL_PATH}/bin
RUN mkdir -p ${MAVEN_PATH} ${KTC_PATH} ${KNPL_PATH} ${GRADLE_PATH}
ENV PATH=${PATH}:${MAVEN_BIN}:${GRADLE_BIN}:${KTC_BIN}:${KNPL_BIN}
##################################################################
# Maven
##################################################################
ENV MAVEN_HOME=${MAVEN_ROOT}
ENV M2_HOME=${MAVEN_ROOT}
ADD ${MAVEN_LINK} /tmp
RUN 7zz x ${MAVEN_TEMP} -o${MAVEN_ROOT}
RUN chmod +x -R ${MAVEN_BIN}
RUN mvn -v
##################################################################
# GRADLE
##################################################################
ADD ${GRADLE_LINK} /tmp
RUN 7zz x ${GRADLE_TEMP} -o${GRADLE_ROOT}
RUN chmod +x -R ${GRADLE_BIN}
RUN gradle -v
##################################################################
# kotlin-compiler
##################################################################
ADD ${KTC_LINK} /tmp
RUN 7zz x ${KTC_TEMP} -o${KTC_ROOT}
RUN chmod +x -R ${KTC_BIN}
RUN kotlin -version
##################################################################
# kotlin-native-prebuilt-linux
##################################################################
ADD ${KNPL_LINK} /tmp
RUN tar -xvzf ${KNPL_TEMP} --directory ${KTC_ROOT}
RUN chmod +x -R ${KNPL_BIN}
##################################################################
# cleanup
##################################################################
RUN echo "clean up" && \
apt-get clean -y && \
apt-get autoclean -y && \
rm -rfv /var/lib/apt/lists/* && \
rm -rfv /tmp/* && \
rm -rfv /var/cache/apt/archives/*.deb

View File

@ -0,0 +1,42 @@
all: app
app:
make build
make deploy
make clean
build:
make pip
python3 kaniko-build.py --version
dry:
make dry-run
test:
make dry-run
dry-run:
python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug --dry-run
pip:
rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED
rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED
rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED
pip install -r requirements.txt
build-compose:
docker-compose build --compress --parallel --progress plain
deploy:
python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.0-debug
deploy-compose:
docker-compose push
clean:
docker container prune -f
docker image prune -f
docker network prune -f
docker volume prune -f
docker system prune -af

View File

@ -0,0 +1,11 @@
#version: '3'
services:
app:
image: "epicmorg/debian:bookworm-jdk19"
build:
context: .
app-develop:
image: "epicmorg/debian:bookworm-develop-jdk19"
build:
context: .
dockerfile: ./Dockerfile.develop

View File

@ -0,0 +1,194 @@
import os
import shutil
import argparse
import yaml
import subprocess
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor, as_completed
from dotenv import load_dotenv
import logging
import sys
# Script version
SCRIPT_VERSION = "1.0.0.1"
# ASCII art for EpicMorg
ASCII_ART = r"""
+=================================================+
| ____| _) \ | |
| __| __ \ | __| |\/ | _ \ __| _` | |
| | | | | ( | | ( | | ( | |
|_____| .__/ _| \___| _| _| \___/ _| \__, | |
| | / _| _) | |___/ |
| ' / _` | __ \ | | / _ \ |
| . \ ( | | | | < ( | |
|_|\_\ \__,_| _| _| _| _|\_\ \___/ |
|\ \ / |
| \ \ \ / __| _` | __ \ __ \ _ \ __||
| \ \ \ / | ( | | | | | __/ | |
| \_/\_/ _| \__,_| .__/ .__/ \___| _| |
| _| _| |
+=================================================+
"""
# Load environment variables from .env file
load_dotenv()
def setup_logging():
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def parse_args():
parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False)
parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file')
parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image')
parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry')
parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup')
parser.add_argument('--version', '-v', action='store_true', help='Show script version')
parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit')
return parser.parse_args()
def load_compose_file(file_path):
with open(file_path, 'r') as file:
return yaml.safe_load(file)
def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry):
kaniko_command = [
'docker', 'run',
'--rm',
'-t',
'-v', f'{os.path.abspath(build_context)}:/workspace',
]
# Add Docker config mounts for both read-only access
kaniko_command.extend([
'-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon
'-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode
])
kaniko_command.extend([
kaniko_image,
'--context', '/workspace',
'--dockerfile', f'/workspace/{dockerfile}',
'--compressed-caching',
'--single-snapshot',
'--cleanup'
])
if deploy:
kaniko_command.extend([
'--destination', image_name
])
elif dry:
kaniko_command.extend([
'--no-push'
])
else:
kaniko_command.extend([
'--no-push'
])
# Add build arguments if they exist
for arg_name, arg_value in build_args.items():
kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}'])
logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}")
process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# Stream output in real-time
for line in process.stdout:
logging.info(line.strip())
process.wait()
if process.returncode == 0:
logging.info(f"Successfully built {service_name}")
else:
for line in process.stderr:
logging.error(line.strip())
logging.error(f"Error building {service_name}")
def show_help():
print(ASCII_ART)
print("EpicMorg: Kaniko-Compose Wrapper\n")
print("Arguments:")
print("--compose-file Path to docker-compose.yml file")
print("--kaniko-image Kaniko executor image")
print("--push, --deploy, -d, -p Deploy the built images to the registry")
print("--dry-run, --dry Dry run: build images without pushing and with cleanup")
print("--version, -v Show script version")
print("--help, -h Show this help message and exit")
def show_version():
print(ASCII_ART)
print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}")
def main():
setup_logging()
args = parse_args()
# Show help and exit if --help is provided
if args.help:
show_help()
return
# Show version and exit if --version or no relevant arguments are provided
if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'):
show_version()
return
compose_file = args.compose_file
kaniko_image = args.kaniko_image
deploy = args.push
dry = args.dry_run
if not os.path.exists(compose_file):
logging.error(f"{compose_file} not found")
return
compose_data = load_compose_file(compose_file)
services = compose_data.get('services', {})
image_names = defaultdict(int)
for service_name, service_data in services.items():
image_name = service_data.get('image')
if not image_name:
logging.warning(f"No image specified for service {service_name}")
continue
image_names[image_name] += 1
for image_name, count in image_names.items():
if count > 1:
logging.error(f"Error: Image name {image_name} is used {count} times.")
return
with ThreadPoolExecutor() as executor:
futures = []
for service_name, service_data in services.items():
build_data = service_data.get('build', {})
build_context = build_data.get('context', '.')
dockerfile = build_data.get('dockerfile', 'Dockerfile')
image_name = service_data.get('image')
build_args = build_data.get('args', {})
# Substitute environment variables with their values if they exist
build_args = {key: os.getenv(key, value) for key, value in build_args.items()}
if not image_name:
logging.warning(f"No image specified for service {service_name}")
continue
futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry))
for future in as_completed(futures):
try:
future.result()
except Exception as exc:
logging.error(f"Generated an exception: {exc}")
if __name__ == '__main__':
main()

View File

@ -0,0 +1,2 @@
PyYAML
python-dotenv