Debian/GraalVM

From Chorke Wiki
Revision as of 09:05, 5 December 2021 by Shahed (talk | contribs) (→‎Install)
Jump to navigation Jump to search

Network Config:

cat <<EOF > /Volumes/boot/wpa_supplicant.conf
country=MY
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
scan_ssid=1
ssid="ChorkeOrg_2.4GHz"
psk="sadaqah!"
}
EOF

System Update:

sudo apt update
sudo apt list --upgradable
sudo apt upgrade

systemctl list-unit-files
systemctl daemon-reload

sudo nmcli dev wifi con 'ChorkeOrg' password 'sadaqah!'
sudo nmcli dev wifi rescan
sudo nmcli dev wifi
sudo nmcli con

Timezone:

sudo timedatectl set-timezone 'Asia/Kuala_Lumpur'
sudo timedatectl set-time '2010-10-10 10:10:10'
sudo hostnamectl set-hostname debian
sudo timedatectl set-ntp true

Cockpit:

https://10.19.83.111:9090/
https://10.19.83.211:9090/
http://10.19.83.111/
http://10.19.83.211/

Install

sudo apt install openjdk-11-jre
sudo apt install openjdk-11-jdk

sudo apt install build-essential libz-dev zlib1g-dev
sudo apt install git
sudo su

export ACADEMIA_HOME="$HOME/.chorke/academia"
mkdir -p $ACADEMIA_HOME/var/download
sudo mkdir -p /opt/cli

mkdir -p $ACADEMIA_HOME/etc/env/
cat << \EOF >> $ACADEMIA_HOME/etc/env/system.sh
# chorke academia env
export ACADEMIA_HOME="$HOME/.chorke/academia"
export ACADEMIA_DEV="$ACADEMIA_HOME/dev"

EOF
cat << \EOF >> $HOME/.bashrc

# chorke academia env
if [ -f "$HOME/.chorke/academia/etc/env/system.sh" ]; then
    source $HOME/.chorke/academia/etc/env/system.sh
fi
EOF

wget -c https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/\
graalvm-ce-java11-linux-aarch64-21.3.0.tar.gz -P $ACADEMIA_HOME/var/download

wget -c https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/\
graalvm-ce-java17-linux-aarch64-21.3.0.tar.gz -P $ACADEMIA_HOME/var/download

sudo tar -xvzf $ACADEMIA_HOME/var/download/\
graalvm-ce-java11-linux-aarch64-21.3.0.tar.gz\
 -C /opt/cli

sudo ln -s /opt/cli/graalvm-ce-java11-21.3.0\
 /usr/lib/jvm/graalvm-ce-java11-21.3.0

sudo update-alternatives --install /usr/bin/java java\
 /usr/lib/jvm/graalvm-ce-java11-21.3.0/bin/java 1

sudo update-alternatives --install /usr/bin/javac javac\
 /usr/lib/jvm/graalvm-ce-java11-21.3.0/bin/javac 1

sudo update-alternatives --install /usr/bin/gu gu\
 /usr/lib/jvm/graalvm-ce-java11-21.3.0/bin/gu 1

sudo gu install native-image
sudo update-alternatives --install /usr/bin/native-image native-image\
 /usr/lib/jvm/graalvm-ce-java11-21.3.0/bin/native-image 1

export GRAALVM_HOME=/usr/lib/jvm/graalvm-ce-java11-21.3.0
sudo tar -xvzf $ACADEMIA_HOME/var/download/\
graalvm-ce-java17-linux-aarch64-21.3.0.tar.gz\
 -C /opt/cli

sudo ln -s /opt/cli/graalvm-ce-java17-21.3.0\
 /usr/lib/jvm/graalvm-ce-java17-21.3.0

sudo update-alternatives --install /usr/bin/java java\
 /usr/lib/jvm/graalvm-ce-java17-21.3.0/bin/java 2

sudo update-alternatives --install /usr/bin/javac javac\
 /usr/lib/jvm/graalvm-ce-java17-21.3.0/bin/javac 2

sudo update-alternatives --install /usr/bin/gu gu\
 /usr/lib/jvm/graalvm-ce-java17-21.3.0/bin/gu 2

sudo gu install native-image
sudo update-alternatives --install /usr/bin/native-image native-image\
 /usr/lib/jvm/graalvm-ce-java17-21.3.0/bin/native-image 2

export GRAALVM_HOME=/usr/lib/jvm/graalvm-ce-java17-21.3.0

sudo update-alternatives --config native-image
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config gu
ls -lah /usr/lib/jvm

Maven

sudo apt install maven
sudo apt install ant
sudo apt install ivy

<profile>
  <id>native-image-fargate</id>
  <build>
    <plugins>
      <plugin>
        <groupId>com.oracle.substratevm</groupId>
        <artifactId>native-image-maven-plugin</artifactId>
        <version>${graal.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>native-image</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
        <configuration>
          <mainClass>${vertx.verticle}</mainClass>
          <imageName>${project.artifactId}</imageName>
          <buildArgs>--enable-all-security-services -H:+ReportUnsupportedElementsAtRuntime --allow-incomplete-classpath</buildArgs>
        </configuration>
      </plugin>
    </plugins>
  </build>
</profile>

Knowledge

sudo apt install snapd
sudo systemctl status snapd
sudo systemctl enable snapd
sudo snap install lxd
sudo systemctl status snapd
sudo systemctl restart snapd
lxc image list images: archlinux arm64
lxc image list images: ubuntu arm64
lxc image list images: alpine arm64

lxc launch images:opensuse/15.3 agronomy
lxc launch images:apertis/v2021 robotics
lxc launch images:alpine/3.15 academia
lxc exec academia sh
lxc exec agronomy sh
lxc exec robotics sh
apt-cache madison docker-ce
docker build -f src/main/docker/Dockerfile.native\
-t quarkus-quickstart/getting-started .

lxc network show lxdbr0 
lxc network list
lxc image list
docker network ls
docker image ls
docker ps -a
export GRAALVM_HOME=/opt/cli/graalvm-ce-java11-21.3.0
mvn compile quarkus:dev
mvn package -Pnative

$GRAALVM_HOME/bin/gu install native-image
sudo apt install icedtea-netx default-jdk
sudo update-alternatives --config java
sudo apt install openjdk-8-jre
sudo apt install openjdk-11-jre
sudo apt install openjdk-17-jre
sudo apt install openjdk-8-jdk
sudo apt install openjdk-11-jdk
sudo apt install openjdk-17-jdk

ssh-keygen -f "/home/chorke/.ssh/known_hosts" -R "10.19.83.111"
ssh-keygen -f ~/.ssh/known_hosts -R 10.19.83.111
apt search upx
sudo apt install upx-ucl

upx -7 -k target/java-native-apps-1.0.0.GA
:'
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2020
UPX 3.96        Markus Oberhumer, Laszlo Molnar & John Reiser   Jan 23rd 2020

         File size         Ratio      Format      Name
    --------------------   ------   -----------   -----------
 1/5  [***************************................................]   26.6%  /
'

References