From 03e32418e8e611554c807db68c87178408865b8a Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 21 Jul 2023 17:40:24 +0200 Subject: [PATCH] graalvm only for clj --- .gitlab-ci.yml | 12 +++- infrastructure/clj/build.py | 56 +++++++++++++++++++ infrastructure/clj/image/Dockerfile | 6 ++ infrastructure/clj/image/resources/CHECKSUMS | 2 + infrastructure/clj/image/resources/install.sh | 38 +++++++++++++ infrastructure/clj/test/.keep | 0 6 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 infrastructure/clj/build.py create mode 100644 infrastructure/clj/image/Dockerfile create mode 100644 infrastructure/clj/image/resources/CHECKSUMS create mode 100755 infrastructure/clj/image/resources/install.sh create mode 100644 infrastructure/clj/test/.keep diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4cdd9e..a6570fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,12 +45,20 @@ pypi-stable: script: - pyb -P version=$CI_COMMIT_TAG publish upload -clojure-image-publish: +clj-cljs-image-publish: <<: *img <<: *tag_only stage: image script: - - cd infrastructure/clojure && pyb image publish + - cd infrastructure/clj-cljs && pyb image publish + +clj-image-publish: + <<: *img + <<: *tag_only + stage: image + script: + - cd infrastructure/clj && pyb image publish + python-image-publish: <<: *img diff --git a/infrastructure/clj/build.py b/infrastructure/clj/build.py new file mode 100644 index 0000000..0fcc289 --- /dev/null +++ b/infrastructure/clj/build.py @@ -0,0 +1,56 @@ +from os import environ +from datetime import datetime +from pybuilder.core import task, init +from ddadevops import * + +name = "ddadevops" +MODULE = "clj" +PROJECT_ROOT_PATH = "../.." +version = "4.2.1-dev" + +@init +def initialize(project): + image_tag = version + if "dev" in image_tag: + image_tag += datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + + input = { + "name": name, + "module": MODULE, + "stage": "notused", + "project_root_path": PROJECT_ROOT_PATH, + "build_types": ["IMAGE"], + "mixin_types": [], + "image_naming": "NAME_AND_MODULE", + "image_tag": f"{image_tag}", + } + + project.build_depends_on("ddadevops>=4.0.0") + + build = DevopsImageBuild(project, input) + build.initialize_build_dir() + + +@task +def image(project): + build = get_devops_build(project) + build.image() + + +@task +def drun(project): + build = get_devops_build(project) + build.drun() + + +@task +def test(project): + build = get_devops_build(project) + build.test() + + +@task +def publish(project): + build = get_devops_build(project) + build.dockerhub_login() + build.dockerhub_publish() diff --git a/infrastructure/clj/image/Dockerfile b/infrastructure/clj/image/Dockerfile new file mode 100644 index 0000000..f02ebd2 --- /dev/null +++ b/infrastructure/clj/image/Dockerfile @@ -0,0 +1,6 @@ +FROM debian:stable-slim + +ADD resources /tmp +RUN /tmp/install.sh +ENV LANG=en_US.UTF-8 \ + JAVA_HOME=/usr/lib64/graalvm/graalvm-community-java17 \ No newline at end of file diff --git a/infrastructure/clj/image/resources/CHECKSUMS b/infrastructure/clj/image/resources/CHECKSUMS new file mode 100644 index 0000000..6a216cd --- /dev/null +++ b/infrastructure/clj/image/resources/CHECKSUMS @@ -0,0 +1,2 @@ +478604fe85c711aafe8ef78c0bf25cb93fa46de5a3c07040f25a595096c43f8a kubeconform-v0.6.3.tar.gz +094e5a7dcc4a903b70741d5c3c1688f83e83e2d44eb3d8d798c5d79ed902032c graalvm-community-jdk-17.0.7_linux-x64_bin.tar.gz \ No newline at end of file diff --git a/infrastructure/clj/image/resources/install.sh b/infrastructure/clj/image/resources/install.sh new file mode 100755 index 0000000..987cf0a --- /dev/null +++ b/infrastructure/clj/image/resources/install.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -eux + +function main() { + upgradeSystem + + apt -qqy install curl git openjdk-17-jre-headless leiningen build-essential libz-dev zlib1g-dev; + + # download kubeconform & graalvm + curl -Lo /tmp/kubeconform-v0.6.3.tar.gz https://github.com/yannh/kubeconform/releases/download/v0.6.3/kubeconform-linux-amd64.tar.gz + curl -Lo /tmp/graalvm-community-jdk-17.0.7_linux-x64_bin.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.7/graalvm-community-jdk-17.0.7_linux-x64_bin.tar.gz + + # checksum + cd /tmp + sha256sum --check CHECKSUMS + + # install kubeconform + tar -xf /tmp/kubeconform-v0.6.3.tar.gz + cp kubeconform /usr/local/bin + + # install graalvm + tar -xzf graalvm-community-jdk-17.0.7_linux-x64_bin.tar.gz + mv graalvm-community-openjdk-17.0.7+7.1 /usr/lib/jvm/ + ln -s /usr/lib/jvm/graalvm-community-openjdk-17.0.7+7.1 /usr/lib/jvm/graalvm + ln -s /usr/lib/jvm/graalvm/bin/gu /usr/local/bin + update-alternatives --install /usr/bin/java java /usr/lib/jvm/graalvm/bin/java 2 + gu install native-image + ln -s /usr/lib/jvm/graalvm/bin/native-image /usr/local/bin + + #install pyb + apt -qqy install python3 python3-pip; + pip3 install pybuilder 'ddadevops>=4.2.0' deprecation dda-python-terraform boto3 pyyaml inflection --break-system-packages; + + cleanupDocker +} + +source /tmp/install_functions.sh +main \ No newline at end of file diff --git a/infrastructure/clj/test/.keep b/infrastructure/clj/test/.keep new file mode 100644 index 0000000..e69de29