Add native build
This commit is contained in:
parent
1c3088630f
commit
24b1abf7af
5 changed files with 173 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,6 +12,7 @@ target/
|
|||
.lein-repl-history
|
||||
.lein-failures
|
||||
pom.*
|
||||
reports/*
|
||||
|
||||
# cljs
|
||||
.shadow-cljs
|
||||
|
|
|
@ -6,7 +6,7 @@ stages:
|
|||
- image
|
||||
|
||||
.img: &img
|
||||
image: "domaindrivenarchitecture/ddadevops-dind:4.10.7"
|
||||
image: "domaindrivenarchitecture/ddadevops-dind:4.11.3"
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
|
@ -16,7 +16,7 @@ stages:
|
|||
- export IMAGE_TAG=$CI_COMMIT_TAG
|
||||
|
||||
.cljs-job: &cljs
|
||||
image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.10.7"
|
||||
image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.11.3"
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}
|
||||
paths:
|
||||
|
@ -29,7 +29,7 @@ stages:
|
|||
- npm install
|
||||
|
||||
.clj-job: &clj
|
||||
image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.10.7"
|
||||
image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.11.3"
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}
|
||||
paths:
|
||||
|
@ -93,6 +93,15 @@ package-uberjar:
|
|||
paths:
|
||||
- target/uberjar
|
||||
|
||||
package-native:
|
||||
<<: *clj
|
||||
stage: package
|
||||
script:
|
||||
- pyb package_native
|
||||
artifacts:
|
||||
paths:
|
||||
- target/graalvm
|
||||
|
||||
release-to-clojars:
|
||||
<<: *clj
|
||||
<<: *tag_only
|
||||
|
|
47
build.py
47
build.py
|
@ -29,6 +29,7 @@ def initialize(project):
|
|||
"release_organisation": "meissa",
|
||||
"release_repository_name": name,
|
||||
"release_artifacts": [
|
||||
f"target/graalvm/{name}",
|
||||
f"target/uberjar/{name}-standalone.jar",
|
||||
f"target/frontend-build/{name}.js",
|
||||
],
|
||||
|
@ -113,11 +114,57 @@ def package_uberjar(project):
|
|||
check=True,
|
||||
)
|
||||
|
||||
@task
|
||||
def package_native(project):
|
||||
run(
|
||||
"mkdir -p target/graalvm",
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
run(
|
||||
"native-image " +
|
||||
"--native-image-info " +
|
||||
"--report-unsupported-elements-at-runtime " +
|
||||
"--no-server " +
|
||||
"--no-fallback " +
|
||||
"--features=clj_easy.graal_build_time.InitClojureClasses " +
|
||||
f"-jar target/uberjar/{project.name}-standalone.jar " +
|
||||
"-H:IncludeResources=.*.yaml " +
|
||||
"-H:Log=registerResource:verbose " +
|
||||
f"-H:Name=target/graalvm/{project.name}",
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
run(
|
||||
f"sha256sum target/graalvm/{project.name} > target/graalvm/{project.name}.sha256",
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
run(
|
||||
f"sha512sum target/graalvm/{project.name} > target/graalvm/{project.name}.sha512",
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
@task
|
||||
def upload_clj(project):
|
||||
run("lein deploy", shell=True, check=True)
|
||||
|
||||
@task
|
||||
def inst(project):
|
||||
package_uberjar(project)
|
||||
package_native(project)
|
||||
run(
|
||||
f"sudo install -m=755 target/uberjar/{project.name}-standalone.jar /usr/local/bin/{project.name}-standalone.jar",
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
run(
|
||||
f"sudo install -m=755 target/graalvm/{project.name} /usr/local/bin/{project.name}",
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
@task
|
||||
def lint(project):
|
||||
|
|
107
doc/Development.md
Normal file
107
doc/Development.md
Normal file
|
@ -0,0 +1,107 @@
|
|||
# Project Setup
|
||||
|
||||
## clj setup
|
||||
|
||||
### install leiningen
|
||||
```
|
||||
sudo apt install leiningen
|
||||
```
|
||||
or manually using Instructions on https://leiningen.org/#install
|
||||
|
||||
### install vscode + extensions
|
||||
```
|
||||
sudo snap install code
|
||||
```
|
||||
or with packages from https://code.visualstudio.com/Download
|
||||
|
||||
install extension "Calva: Clojure & ClojureScript Interactive Programming"
|
||||
|
||||
## cljs / js-dev setup
|
||||
|
||||
```
|
||||
sudo apt install npm
|
||||
sudo npm install -g npx
|
||||
|
||||
# maybe
|
||||
sudo npm install -g shadow-cljs
|
||||
|
||||
# in project root to retrieve all dependencies
|
||||
npm install --ignore-scripts
|
||||
npx shadow-cljs compile test
|
||||
```
|
||||
|
||||
### create frontend script
|
||||
|
||||
```
|
||||
npx shadow-cljs release frontend
|
||||
```
|
||||
|
||||
## graalvm-setup
|
||||
|
||||
```
|
||||
curl -LO https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz
|
||||
|
||||
# unpack
|
||||
tar -xzf graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz
|
||||
|
||||
sudo mv graalvm-community-openjdk-21.0.2+13.1 /usr/lib/jvm/
|
||||
sudo ln -s /usr/lib/jvm/graalvm-community-openjdk-21.0.2+13.1 /usr/lib/jvm/graalvm-21
|
||||
sudo ln -s /usr/lib/jvm/graalvm-21/bin/gu /usr/local/bin
|
||||
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/graalvm-21/bin/java 2
|
||||
sudo update-alternatives --config java
|
||||
sudo ln -s /usr/lib/jvm/graalvm-21/bin/native-image /usr/local/bin
|
||||
|
||||
# deps
|
||||
sudo apt-get install build-essential libz-dev zlib1g-dev
|
||||
|
||||
# build
|
||||
cd ~/repo/c4k/c4k-forgejo
|
||||
lein uberjar
|
||||
mkdir -p target/graalvm
|
||||
lein native
|
||||
|
||||
# execute
|
||||
./target/graalvm/c4k-cloud -h
|
||||
./target/graalvm/c4k-cloud src/test/resources/valid-config.edn src/test/resources/valid-auth.edn
|
||||
./target/graalvm/c4k-cloud src/test/resources/invalid-config.edn src/test/resources/invalid-auth.edn
|
||||
```
|
||||
|
||||
## c4k-setup
|
||||
### install kubectl
|
||||
|
||||
```
|
||||
sudo -i
|
||||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
||||
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" \
|
||||
| tee -a /etc/apt/sources.list.d/kubernetes.list
|
||||
apt update && apt install kubectl
|
||||
kubectl completion bash >> /etc/bash_completion.d/kubernetes
|
||||
```
|
||||
|
||||
### install kubeconform
|
||||
|
||||
```
|
||||
curl -Lo /tmp/kubeconform.tar.gz https://github.com/yannh/kubeconform/releases/download/v0.4.7/kubeconform-linux-amd64.tar.gz
|
||||
tar -xf /tmp/kubeconform.tar.gz
|
||||
sudo cp kubeconform /usr/local/bin
|
||||
```
|
||||
|
||||
### remote access to c4k
|
||||
|
||||
```
|
||||
scp -r root@devops.test.meissa-gmbh.de:/home/c4k/.kube ~/
|
||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@devops.test.meissa-gmbh.de -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
|
||||
|
||||
# add in /etc/hosts "127.0.0.1 kubernetes"
|
||||
|
||||
# change in ~/.kube/config 192.168.5.1 -> kubernetes
|
||||
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
### deploy cloud
|
||||
|
||||
```
|
||||
java -jar target/uberjar/c4k-cloud-standalone.jar valid-config.edn valid-auth.edn | kubeconform --kubernetes-version 1.19.0 --strict --skip Certificate -
|
||||
java -jar target/uberjar/c4k-cloud-standalone.jar valid-config.edn my-auth.edn | kubectl apply -f -
|
||||
```
|
23
project.clj
23
project.clj
|
@ -4,7 +4,7 @@
|
|||
:license {:name "Apache License, Version 2.0"
|
||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||
[org.clojure/tools.reader "1.3.7"]
|
||||
[org.clojure/tools.reader "1.4.0"]
|
||||
[org.domaindrivenarchitecture/c4k-common-clj "6.1.3"]
|
||||
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
|
||||
:target-path "target/%s/"
|
||||
|
@ -22,25 +22,14 @@
|
|||
:uberjar {:aot :all
|
||||
:main dda.c4k-taiga.uberjar
|
||||
:uberjar-name "c4k-taiga-standalone.jar"
|
||||
:dependencies [[org.clojure/tools.cli "1.0.219"]
|
||||
[ch.qos.logback/logback-classic "1.4.14"
|
||||
:dependencies [[org.clojure/tools.cli "1.1.230"]
|
||||
[ch.qos.logback/logback-classic "1.5.0"
|
||||
:exclusions [com.sun.mail/javax.mail]]
|
||||
[org.slf4j/jcl-over-slf4j "2.0.11"]]}}
|
||||
[org.slf4j/jcl-over-slf4j "2.0.12"]
|
||||
[com.github.clj-easy/graal-build-time "1.0.5"]]}}
|
||||
:release-tasks [["test"]
|
||||
["vcs" "assert-committed"]
|
||||
["change" "version" "leiningen.release/bump-version" "release"]
|
||||
["vcs" "commit"]
|
||||
["vcs" "tag" "v" "--no-sign"]
|
||||
["change" "version" "leiningen.release/bump-version"]]
|
||||
:aliases {"native" ["shell"
|
||||
"native-image"
|
||||
"--report-unsupported-elements-at-runtime"
|
||||
"--initialize-at-build-time"
|
||||
"-jar" "target/uberjar/c4k-taiga-standalone.jar"
|
||||
"-H:ResourceConfigurationFiles=graalvm-resource-config.json"
|
||||
"-H:Log=registerResource"
|
||||
"-H:Name=target/graalvm/${:name}"]
|
||||
"inst" ["shell"
|
||||
"sh"
|
||||
"-c"
|
||||
"lein uberjar && sudo install -m=755 target/uberjar/c4k-taiga-standalone.jar /usr/local/bin/c4k-taiga-standalone.jar"]})
|
||||
["change" "version" "leiningen.release/bump-version"]])
|
||||
|
|
Loading…
Reference in a new issue