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

feat: TractusX EDC Custom Build #359

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
52 changes: 52 additions & 0 deletions .github/workflows/verify-custom-tractusx-edc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#################################################################################
#
# Copyright (c) 2024 SAP SE
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# SAP SE - initial API and implementation
#
#################################################################################

---
name: "Custom TractusX EDC"

on:
push:
branches:
- main
paths:
- 'custom-tractusx-edc/**'

pull_request:
branches:
- main
paths:
- 'custom-tractusx-edc/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

Build-Custom-TractusX-EDC:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '22'

- run: ./gradlew clean dockerize
working-directory: custom-tractusx-edc
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ override.tf.json
.terraformrc
terraform.rc

.gradle
build

.idea/
mxd/.terraform.lock.hcl
12 changes: 12 additions & 0 deletions custom-tractusx-edc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Custom Tractus-X EDC (Eclipse Dataspace Connector)

A customized [Tractus-X EDC](https://github.com/eclipse-tractusx/tractusx-edc) Build.

## Getting Started

### Build
Build Tractus-X EDC together with its Container Images

```shell
./gradlew clean dockerize
```
103 changes: 103 additions & 0 deletions custom-tractusx-edc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/********************************************************************************
* Copyright (c) 2024 SAP SE
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* SAP SE - initial API and implementation
*
********************************************************************************/

import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
import java.time.Duration

plugins {
`java-library`
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.bmuschko.docker-remote-api") version "9.4.0"
hemantxpatel marked this conversation as resolved.
Show resolved Hide resolved
}

val edcVersion = libs.versions.edc

buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath(libs.edc.build.plugin)
}
}

allprojects {
apply(plugin = "org.eclipse.edc.edc-build")

repositories {
mavenCentral()
}

// configure which version of the annotation processor to use. defaults to the same version as the plugin
configure<org.eclipse.edc.plugins.autodoc.AutodocExtension> {
processorVersion.set(edcVersion)
outputDirectory.set(project.layout.buildDirectory.asFile.get())
}
}

// the "dockerize" task is added to all projects that use the `shadowJar` plugin
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.github.johnrengelman.shadow") &&
file("${project.projectDir}/src/main/docker/Dockerfile").exists()
) {
val buildDir = project.layout.buildDirectory.get().asFile

val agentFile = buildDir.resolve("opentelemetry-javaagent.jar")
// create task to download the opentelemetry agent
val openTelemetryAgentUrl = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.32.0/opentelemetry-javaagent.jar"
hemantxpatel marked this conversation as resolved.
Show resolved Hide resolved
val downloadOtel = tasks.create("downloadOtel") {
// only execute task if the opentelemetry agent does not exist. invoke the "clean" task to force
onlyIf {
!agentFile.exists()
}
// this task could be the first in the graph, so "build/" may not yet exist. Let's be defensive
doFirst {
buildDir.mkdirs()
}
// download the jar file
doLast {
val download = { url: String, destFile: File ->
ant.invokeMethod(
"get",
mapOf("src" to url, "dest" to destFile)
)
}
logger.lifecycle("Downloading OpenTelemetry Agent")
download(openTelemetryAgentUrl, agentFile)
}
}

//actually apply the plugin to the (sub-)project
apply(plugin = "com.bmuschko.docker-remote-api")
// configure the "dockerize" task
val dockerTask: DockerBuildImage = tasks.create("dockerize", DockerBuildImage::class) {
val dockerContextDir = project.projectDir
dockerFile.set(file("$dockerContextDir/src/main/docker/Dockerfile"))
images.add("${project.name}:${project.version}")
images.add("${project.name}:latest")
// specify platform with the -Dplatform flag:
if (System.getProperty("platform") != null)
platform.set(System.getProperty("platform"))
buildArgs.put("JAR", "build/libs/${project.name}.jar")
buildArgs.put("OTEL_JAR", agentFile.relativeTo(dockerContextDir).path.replace("\\", "/"))
inputDir.set(file(dockerContextDir))
}
dockerTask
.dependsOn(tasks.named(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME))
.dependsOn(downloadOtel)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/********************************************************************************
* Copyright (c) 2024 SAP SE
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* SAP SE - initial API and implementation
*
********************************************************************************/

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
`java-library`
id("application")
id("com.github.johnrengelman.shadow") version "8.1.1"
hemantxpatel marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
runtimeOnly(libs.edc.controlplane.postgresql.hashicorp.vault) {
exclude(module = "tx-iatp-sts-dim")
}
runtimeOnly(libs.edc.identity.trust.sts.remote.client)
runtimeOnly(libs.edc.auth.oauth2.client)
}

tasks.withType<ShadowJar> {
exclude("**/pom.properties", "**/pom.xm")
hemantxpatel marked this conversation as resolved.
Show resolved Hide resolved
mergeServiceFiles()
archiveFileName.set("${project.name}.jar")
}

application {
mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime")
}

// do not publish
edcBuild {
publish.set(false)
}
hemantxpatel marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#################################################################################
#
# Copyright (c) 2024 SAP SE
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# SAP SE - initial API and implementation
#
#################################################################################


FROM eclipse-temurin:22.0.1_8-jre-alpine
ARG JAR
ARG OTEL_JAR
ARG ADDITIONAL_FILES

ARG APP_USER=docker
ARG APP_UID=10100

RUN addgroup --system "$APP_USER"

RUN adduser \
--shell /sbin/nologin \
--disabled-password \
--gecos "" \
--ingroup "$APP_USER" \
--no-create-home \
--uid "$APP_UID" \
"$APP_USER"

USER "$APP_USER"
WORKDIR /app

COPY ${JAR} edc-controlplane.jar
COPY ${OTEL_JAR} opentelemetry-javaagent.jar
COPY ${ADDITIONAL_FILES} ./

HEALTHCHECK NONE

CMD ["java", \
"-javaagent:/app/opentelemetry-javaagent.jar", \
"-Dedc.fs.config=/app/configuration.properties", \
"-Djava.util.logging.config.file=/app/logging.properties", \
"-Dotel.javaagent.configuration-file=/app/opentelemetry.properties", \
"-Dotel.metrics.exporter=prometheus", \
"-Dotel.exporter.prometheus.port=9090", \
"-Djava.security.egd=file:/dev/urandom", \
"-jar", \
"edc-controlplane.jar"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/********************************************************************************
* Copyright (c) 2024 SAP SE
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* SAP SE - initial API and implementation
*
********************************************************************************/

plugins {
`java-library`
id("application")
id("com.github.johnrengelman.shadow") version "8.1.1"
}

dependencies {
runtimeOnly(libs.edc.dataplane.hashicorp.vault) {
exclude(module = "tx-iatp-sts-dim")
}
runtimeOnly(libs.edc.identity.trust.sts.remote.client)
runtimeOnly(libs.edc.auth.oauth2.client)
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
exclude("**/pom.properties", "**/pom.xm")
mergeServiceFiles()
archiveFileName.set("${project.name}.jar")
}

application {
mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime")
}

// do not publish
edcBuild {
publish.set(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#################################################################################
#
# Copyright (c) 2024 SAP SE
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# SAP SE - initial API and implementation
#
#################################################################################


FROM eclipse-temurin:22.0.1_8-jre-alpine
ARG JAR
ARG OTEL_JAR
ARG ADDITIONAL_FILES

ARG APP_USER=docker
ARG APP_UID=10100

RUN addgroup --system "$APP_USER"

RUN adduser \
--shell /sbin/nologin \
--disabled-password \
--gecos "" \
--ingroup "$APP_USER" \
--no-create-home \
--uid "$APP_UID" \
"$APP_USER"

USER "$APP_USER"
WORKDIR /app

COPY ${JAR} edc-dataplane.jar
COPY ${OTEL_JAR} opentelemetry-javaagent.jar
COPY ${ADDITIONAL_FILES} ./


HEALTHCHECK NONE

CMD ["java", \
"-javaagent:/app/opentelemetry-javaagent.jar", \
"-Dedc.fs.config=/app/configuration.properties", \
"-Djava.util.logging.config.file=/app/logging.properties", \
"-Dotel.javaagent.configuration-file=/app/opentelemetry.properties", \
"-Dotel.metrics.exporter=prometheus", \
"-Dotel.exporter.prometheus.port=9090", \
"-Djava.security.egd=file:/dev/urandom", \
"-jar", \
"edc-dataplane.jar"]
17 changes: 17 additions & 0 deletions custom-tractusx-edc/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#################################################################################
#
# Copyright (c) 2024 SAP SE
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# SAP SE - initial API and implementation
#
#################################################################################

group=org.eclipse.tractusx.edc
version=0.7.2
Loading
Loading