diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..5577d9ff --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build Docker image + +on: + push: + branches: + - "*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Gradle build with cache + uses: burrunan/gradle-cache-action@v1 + with: + arguments: "bootJar" + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: "./maestro-server" + dockerfile: "./maestro-server/Dockerfile" + platforms: linux/amd64,linux/arm64 + push: true + tags: datacatering/maestro:0.1.0 diff --git a/maestro-server/Dockerfile b/maestro-server/Dockerfile new file mode 100644 index 00000000..9c47b647 --- /dev/null +++ b/maestro-server/Dockerfile @@ -0,0 +1,11 @@ +FROM openjdk:21-slim as builder +ARG JAR_FILE=build/libs/maestro-server.jar +COPY ${JAR_FILE} application.jar +RUN java -Djarmode=layertools -jar application.jar extract + +FROM openjdk:21-slim +COPY --from=builder dependencies/ ./ +COPY --from=builder snapshot-dependencies/ ./ +COPY --from=builder spring-boot-loader/ ./ +COPY --from=builder application/ ./ +ENTRYPOINT ["java", "-Djava.security.manager=allow", "org.springframework.boot.loader.JarLauncher"] \ No newline at end of file diff --git a/maestro-server/README.md b/maestro-server/README.md index 117b2929..00c3ecf8 100644 --- a/maestro-server/README.md +++ b/maestro-server/README.md @@ -1,3 +1,37 @@ Maestro Server =================================== This module includes a Springboot app implementation of Maestro server. + +## Docker + +### Build + +Build the JAR file and Docker image via: + +```shell +./gradlew bootJar +docker build -t maestro-server:0.1 maestro-server +``` + +### Run + +Assuming you have CockroachDB already setup and running ([otherwise check these steps](#cockroachdb)): + +```shell +docker run \ + --name maestro \ + --network host \ + -p 8080:8080 \ + -e CONDUCTOR_CONFIGS_JDBCURL=jdbc:postgresql://localhost:26257/maestro \ + -e CONDUCTOR_CONFIGS_JDBCUSERNAME=root \ + maestro-server:0.1 +``` + +#### CockroachDB + +Spin up CockroachDB with `maestro` database via the below commands: + +```shell +docker run -d -p 26257:26257 --name cockroachdb cockroachdb/cockroach:v24.1.0 start-single-node --insecure +docker exec cockroachdb cockroach sql --insecure --execute 'CREATE DATABASE maestro;' +``` diff --git a/maestro-server/build.gradle b/maestro-server/build.gradle index 9960119a..6bee12df 100644 --- a/maestro-server/build.gradle +++ b/maestro-server/build.gradle @@ -32,6 +32,12 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.+' } +bootJar { + layered { + enabled = true + } +} + bootRun { jvmArgs += ["-Djava.security.manager=allow"] }