Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker with GitHub actions #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions maestro-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
34 changes: 34 additions & 0 deletions maestro-server/README.md
Original file line number Diff line number Diff line change
@@ -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;'
```
6 changes: 6 additions & 0 deletions maestro-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand Down