--- title: Build from source tags: ThingsBoard image: https://i.imgur.com/3XwcppD.png disqus: hackmd --- Build TB from Source === :::info 編譯TB的VM環境盡可能乾淨,也不要有執行過TB Docker的部署,可能會導致衝突。 ::: * https://thingsboard.io/docs/user-guide/install/building-from-source/ Prerequisites --- >**JDK** ``` ###Ubuntu 20.04.2 LTS sudo apt update sudo apt install openjdk-11-jdk sudo update-alternatives --config java star@tb:~$ java -version openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing) ``` >**Maven** ``sudo apt-get install maven `` ``` star@tb:~$ mvn -v Apache Maven 3.6.3 Maven home: /usr/share/maven Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.4.0-74-generic", arch: "amd64", family: "unix" ``` >**Checkout TB 3.2.2 repository** (plz update 3.4 instead) ``` git clone https://github.com/thingsboard/thingsboard.git cd thingsboard git checkout release-3.2 ``` Build --- > BUILD FAILURE :mask: ``` mvn clean install ``` ![](https://i.imgur.com/yNE85M6.png) > BUILD SUCCESS (==vCPUx2, 4G Mem==), 跳過單元測試,如果遇到 err 137 相關,請擴充記憶體至6G。 ``` mvn clean install -DskipTests ``` ![](https://i.imgur.com/3XwcppD.png) We can find debian, rpm and windows packages in the target folder: **application/target** :::info If you need to generate local docker images, please build as below! ::: ### Build local docker images > [Install Docker](./hMV_J0mWRGeRJyKLjjTZww?view#Install-Docker-CE) > gnupg2 package ``` ###Update Dockerfile #./msa/tb/docker-postgres/Dockerfile FROM thingsboard/openjdk11 RUN apt-get update RUN apt-get install -y curl gnupg2 #./msa/tb/docker-cassandra/Dockerfile FROM thingsboard/openjdk11 RUN apt-get update RUN apt-get install -y curl nmap procps gnupg2 ``` > BUILD SUCCESS * Your build account (e.g. star) needs to be in the docker group ``sudo usermod -aG docker star`` ``` mvn clean install -DskipTests -Ddockerfile.skip=false ``` ![](https://i.imgur.com/4pZGci5.png) ``` star@tb:~/workspace/thingsboard/msa/tb/target$ ls -hl total 4.9M drwxrwxr-x 2 star star 4.0K Jun 18 02:31 docker drwxrwxr-x 2 star star 4.0K Jun 18 02:30 docker-cassandra drwxrwxr-x 2 star star 4.0K Jun 18 02:30 docker-postgres drwxrwxr-x 2 star star 4.0K Jun 18 02:30 docker-tb drwxrwxr-x 2 star star 4.0K Jun 18 02:31 maven-archiver -rw-rw-r-- 1 star star 4.9M Jun 18 02:30 protoc-3.11.4-linux-x86_64.exe -rw-rw-r-- 1 star star 4.2K Jun 18 02:36 tb-3.2.2-docker-info.jar drwxrwxr-x 3 star star 4.0K Jun 18 02:31 test-classes ``` :::spoiler Re-run Maven using the -X switch to enable full debug logging e.g. build with the command mvn clean install -DskipTests -X to get verbose output ::: Resource(s) --- * [Facebook ThingsBoard Taiwan Group](https://facebook.com/groups/thingsboard)