Skip to content

Commit

Permalink
feat: update build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
enix223 committed May 24, 2024
1 parent 70554aa commit 54e3bcb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 76 deletions.
39 changes: 6 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
jdk: [17.0.11_9, 11.0.23_9, 8u412-b08]
platforms: [linux/amd64, linux/arm64/v8]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -41,40 +43,11 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64, linux/arm64/v8
platforms: ${{ matrix.platforms }}
build-args: |
JDKVER=17.0.9_9
JDKVER=${{ matrix.jdk }}
TDVERSION=${{ steps.get_latest_tag.outputs.tag }}
file: Dockerfile
push: true
tags: |
enix223/tdengine-openjdk-client:17.0.9_9-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
enix223/tdengine-openjdk-client:17-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
- name: Build 11-jdk-focal
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64, linux/arm64/v8
build-args: |
JDKVER=11.0.21_9
TDVERSION=${{ steps.get_latest_tag.outputs.tag }}
file: Dockerfile
push: true
tags: |
enix223/tdengine-openjdk-client:11.0.21_9-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
enix223/tdengine-openjdk-client:11-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
- name: Build 8-jdk-focal
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64, linux/arm64/v8
build-args: |
JDKVER=8u392-b08
TDVERSION=${{ steps.get_latest_tag.outputs.tag }}
file: Dockerfile
push: true
tags: |
enix223/tdengine-openjdk-client:8u392-b08-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
enix223/tdengine-openjdk-client:8-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
enix223/tdengine-openjdk-client:${{ matrix.jdk }}-jdk-focal-${{ steps.get_latest_tag.outputs.tag }}
37 changes: 19 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
ARG JDKVER=17.0.9_9
FROM ubuntu:focal AS build-env
ARG TDVERSION=3.0.2.5
ARG TDVERSION_FULL=ver-${TDVERSION}

WORKDIR /tdengine
ARG JDKVER=17.0.11_9
FROM eclipse-temurin:${JDKVER}-jdk-focal
ARG TDVERSION=3.3.0.3
ARG TARGETARCH

RUN apt-get update
RUN apt-get install -y tzdata libgeos-dev
RUN apt-get install -y gcc cmake build-essential git libssl-dev libgflags2.2 libgflags-dev libaprutil1-dev
RUN apt-get install -y build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config
RUN apt-get install -y netcat
ADD taos.cfg /etc/taos/taos.cfg

RUN git clone --depth=1 -b ${TDVERSION_FULL} https://github.com/taosdata/TDengine .
RUN git submodule update --init --recursive
RUN mkdir debug && cd debug && cmake .. -DBUILD_JDBC=false -DBUILD_TOOLS=false -DBUILD_HTTP=false && make && make install
WORKDIR /tmp

RUN if [ "$TARGETARCH" = "linux/arm64/v8" ]; then \
export ARCH=arm64; \
else \
export ARCH=x64; \
fi && curl -o tdengine.tar.gz https://www.tdengine.com/assets-download/3.0/TDengine-client-${TDVERSION}-Linux-$ARCH.tar.gz
RUN tar -xf tdengine.tar.gz
RUN cp TDengine-client-${TDVERSION}/driver/libtaos.so.${TDVERSION} /usr/lib/
RUN cp TDengine-client-${TDVERSION}/driver/libtaosws.so /usr/lib/

FROM eclipse-temurin:${JDKVER}-jdk-focal
ARG TDVERSION
RUN apt-get update
RUN apt-get install -y netcat
ADD taos.cfg /etc/taos/taos.cfg
COPY --from=build-env /tdengine/debug/build/lib/libtaos.so.${TDVERSION} /usr/lib/libtaos.so.${TDVERSION}
RUN ln -s /usr/lib/libtaos.so.${TDVERSION} /usr/lib/libtaos.so
RUN ln -s /usr/lib/libtaos.so.${TDVERSION} /usr/lib/libtaos.so.1

RUN rm -rf /tmp/TDengine-client-*

WORKDIR /
2 changes: 1 addition & 1 deletion LATEST_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2.4
3.3.0.3
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Argument:

* JDKVER - OpenJDK image tag, default to **17.0.6_10**
* TDVERSION - TDEngine version, default to **3.0.2.3**
* TARGETARCH - github action os target arch


### 3.1 Build focal image
Expand All @@ -53,21 +54,7 @@ docker build \
-f Dockerfile_focal \
--build-arg JDKVER=17.0.6_10 \
--build-arg TDVERSION=3.0.2.5 \
--build-arg TARGETARCH=linux/arm64/v8 \
--tag enix223/tdengine-openjdk-client:17.0.6_10-jdk-focal-3.0.2.5 \
--tag enix223/tdengine-openjdk-client:17-jdk-focal-3.0.2.5 \
.
```

### 3.2 Build alpine image

docker pull eclipse-temurin:17.0.6_10-jdk-alpine

```shell
docker build \
-f Dockerfile_alpine \
--build-arg JDKVER=17.0.6_10 \
--build-arg TDVERSION=3.0.2.5 \
--tag enix223/tdengine-openjdk-client:17.0.6_10-jdk-alpine-3.0.2.5 \
--tag enix223/tdengine-openjdk-client:17-jdk-alpine-3.0.2.5 \
.
```
4 changes: 2 additions & 2 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ init:
--hostname=tdengine \
-p 6030-6041:6030-6041 \
-p 6030-6041:6030-6041/udp \
tdengine/tdengine:3.0.2.5
tdengine/tdengine:3.3.0.3

prepare: init
sleep 5 && docker exec -it tdengine-openjdk-demo taos -s "create database db"
Expand All @@ -19,7 +19,7 @@ run: package
docker run -it --rm -v $(PWD)/target/tdengine-demo-1.0-SNAPSHOT-jar-with-dependencies.jar:/tdengine-demo.jar \
-v $(PWD)/taos.cfg:/etc/taos/taos.cfg \
--add-host=tdengine:$$IP \
enix223/tdengine-openjdk-client:17-3.0.2.5 \
enix223/tdengine-openjdk-client:17-jdk-focal-3.3.0.3 \
java -jar /tdengine-demo.jar

clean:
Expand Down
14 changes: 7 additions & 7 deletions example/src/main/java/com/enixyu/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ public class App {
public static void main(String[] args) {
try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
String jdbcUrl = "jdbc:TAOS://tdengine:6030/db?user=root&password=taosdata";
String jdbcUrl = "jdbc:TAOS://tdengine:6030/log?user=root&password=taosdata";
Connection conn = DriverManager.getConnection(jdbcUrl);

Statement stmt = conn.createStatement();
// create database
stmt.executeUpdate("create database if not exists db");
stmt.executeUpdate("create database if not exists demo");
// use database
stmt.executeUpdate("use db");
stmt.executeUpdate("use demo");
// create table
stmt.executeUpdate(
"create table if not exists tb (ts timestamp, temperature int, humidity float)");
"create table if not exists metric (ts timestamp, temperature int, humidity float)");
// insert data
int affectedRows = stmt.executeUpdate(
"insert into tb values(now, 23, 10.3) (now + 1s, 20, 9.3)");
"insert into metric values(now, 23, 10.3) (now + 1s, 20, 9.3)");

System.out.println("insert " + affectedRows + " rows.");

// query data
ResultSet resultSet = stmt.executeQuery("select * from tb");
ResultSet resultSet = stmt.executeQuery("select * from metric");
Timestamp ts = null;
int temperature = 0;
float humidity = 0;
Expand All @@ -48,7 +48,7 @@ public static void main(String[] args) {

// get metadata
var metadata = conn.getMetaData().unwrap(TSDBDatabaseMetaData.class);
var cols = metadata.getColumns("db", "", "tb", "");
var cols = metadata.getColumns("demo", "", "metric", "");
while (cols.next()) {
var name = cols.getString("COLUMN_NAME");
var type = cols.getString("DATA_TYPE");
Expand Down

0 comments on commit 54e3bcb

Please sign in to comment.