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

refactor: avoid Dockerfile duplication #1430

Merged
Merged
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
3 changes: 1 addition & 2 deletions .github/actions/publish-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ runs:
# "jq -r" removes the quotation marks, that would trip up "wget"
URL=$(grep "val openTelemetryAgentUrl = " build.gradle.kts | awk -F'= ' '{print $2}' | jq -r)
wget -O ${{ inputs.rootDir }}/opentelemetry-javaagent.jar -q $URL


#####################
# Login to DockerHub
Expand Down Expand Up @@ -103,7 +102,7 @@ runs:
uses: docker/build-push-action@v3
with:
context: .
file: ${{ inputs.rootDir }}/src/main/docker/Dockerfile
file: ${{ inputs.rootDir }}/build/Dockerfile
build-args: |
JAR=${{ inputs.rootDir }}/build/libs/${{ inputs.imagename }}.jar
OTEL_JAR=${{ inputs.rootDir }}/opentelemetry-javaagent.jar
Expand Down
15 changes: 11 additions & 4 deletions .github/actions/run-deployment-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ description: "Build and publish a Docker Image to DockerHub"
inputs:
imagename:
required: true
description: "name of the docker image, e.g. edc-runtime-memory"
description: "list of docker image names separated by whitespace, e.g. 'edc-runtime-memory edc-runtime-other'"

image_tag:
required: false
Expand All @@ -38,7 +38,7 @@ inputs:

rootDir:
required: true
description: "The directory that contains the docker file, e.g. edc-controlplane/edc-runtime-memory"
description: "list of directories of the modules to be dockerized, separated by whitespace, e.g. 'edc-controlplane/edc-runtime-memory edc-dataplane/edc-dataplane-memory'"

k8sversion:
required: false
Expand Down Expand Up @@ -69,12 +69,19 @@ runs:
- name: Build docker images
shell: bash
run: |-
./gradlew -p ${{ inputs.rootDir }} dockerize
modules=(${{ inputs.rootDir }})
for module in "${modules[@]}"
do
./gradlew -p $module dockerize
done

- name: Load images into KinD
shell: bash
run: |
kind get clusters | xargs -n1 kind load docker-image ${{ inputs.imagename }}:${{ inputs.image_tag }} --name
images=(${{ inputs.imagename }})
versioned=( "${images[@]/%/:${{ inputs.image_tag }}}" )
versioned_images=$(IFS=' ' ; echo "${versioned[*]}")
kind get clusters | xargs -n1 kind load docker-image $versioned_images --name

###################################################
# Install the test infrastructure
Expand Down
56 changes: 1 addition & 55 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,61 +47,7 @@ updates:
# Docker
- package-ecosystem: "docker"
target-branch: main
directory: ./edc-controlplane/edc-controlplane-postgresql-azure-vault/src/main/docker/
labels:
- "dependabot"
- "docker"
schedule:
interval: "weekly"
-
package-ecosystem: "docker"
target-branch: main
directory: ./edc-controlplane/edc-controlplane-postgresql-hashicorp-vault/src/main/docker/
labels:
- "dependabot"
- "docker"
schedule:
interval: "weekly"
-
package-ecosystem: "docker"
target-branch: main
directory: ./edc-controlplane/edc-runtime-memory/src/main/docker/
labels:
- "dependabot"
- "docker"
schedule:
interval: "weekly"
-
package-ecosystem: "docker"
target-branch: main
directory: ./edc-dataplane/edc-dataplane-azure-vault/src/main/docker/
labels:
- "dependabot"
- "docker"
schedule:
interval: "weekly"
-
package-ecosystem: "docker"
target-branch: main
directory: ./edc-dataplane/edc-dataplane-hashicorp-vault/src/main/docker/
labels:
- "dependabot"
- "docker"
schedule:
interval: "weekly"
-
package-ecosystem: "docker"
target-branch: main
directory: ./edc-tests/runtime/mock-connector/src/main/docker/
labels:
- "dependabot"
- "docker"
schedule:
interval: "weekly"
-
package-ecosystem: "docker"
target-branch: main
directory: ./samples/edc-dast/edc-dast-runtime/src/main/docker/
directory: .
labels:
- "dependabot"
- "docker"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployment-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
name: "Run deployment test using KinD and Helm"
with:
imagename: "edc-controlplane-postgresql-hashicorp-vault edc-dataplane-hashicorp-vault"
rootDir: "."
rootDir: "edc-controlplane/edc-controlplane-postgresql-hashicorp-vault edc-dataplane/edc-dataplane-hashicorp-vault"
k8sversion: ${{ matrix.k8s-version }}
helm_command: |-
helm install tx-prod charts/tractusx-connector \
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
name: "Run deployment test using KinD and Helm"
with:
imagename: "edc-controlplane-postgresql-azure-vault edc-dataplane-azure-vault"
rootDir: "."
rootDir: "edc-controlplane/edc-controlplane-postgresql-azure-vault edc-dataplane/edc-dataplane-azure-vault"
helm_command: |-
az keyvault secret set --vault-name ${{ secrets.AZURE_VAULT_NAME }} --name aes-keys --value "$(cat aes.key)" > /dev/null
az keyvault secret set --vault-name ${{ secrets.AZURE_VAULT_NAME }} --name client-secret --value "$(cat client.secret)" > /dev/null
Expand Down
8 changes: 4 additions & 4 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
maven/mavencentral/com.apicatalog/carbon-did/0.3.0, Apache-2.0, approved, clearlydefined

Check warning on line 1 in DEPENDENCIES

View workflow job for this annotation

GitHub Actions / verify / verify-dependencies / Dash-Verify-Licenses

Restricted Dependencies found

Some dependencies are marked 'restricted' - please review them
maven/mavencentral/com.apicatalog/copper-multibase/0.5.0, Apache-2.0, approved, #14501
maven/mavencentral/com.apicatalog/copper-multicodec/0.1.1, Apache-2.0, approved, #14500
maven/mavencentral/com.apicatalog/iron-ed25519-cryptosuite-2020/0.14.0, Apache-2.0, approved, #14503
Expand Down Expand Up @@ -71,7 +71,7 @@
maven/mavencentral/com.github.docker-java/docker-java-api/3.3.6, Apache-2.0, approved, #10346
maven/mavencentral/com.github.docker-java/docker-java-api/3.4.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.github.docker-java/docker-java-transport-zerodep/3.3.6, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #15251
maven/mavencentral/com.github.docker-java/docker-java-transport-zerodep/3.4.0, Apache-2.0, restricted, clearlydefined
maven/mavencentral/com.github.docker-java/docker-java-transport-zerodep/3.4.0, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #15745
maven/mavencentral/com.github.docker-java/docker-java-transport/3.3.6, Apache-2.0, approved, #7942
maven/mavencentral/com.github.docker-java/docker-java-transport/3.4.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.github.java-json-tools/btf/1.3, Apache-2.0 OR LGPL-3.0-only, approved, #15201
Expand Down Expand Up @@ -318,7 +318,7 @@
maven/mavencentral/org.apache.maven.doxia/doxia-sink-api/1.12.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.apache.velocity.tools/velocity-tools-generic/3.1, Apache-2.0, approved, #9331
maven/mavencentral/org.apache.velocity/velocity-engine-core/2.3, Apache-2.0, approved, #2478
maven/mavencentral/org.apache.velocity/velocity-engine-scripting/2.3, Apache-2.0, restricted, clearlydefined
maven/mavencentral/org.apache.velocity/velocity-engine-scripting/2.3, Apache-2.0 AND BSD-3-Clause, approved, #15744
maven/mavencentral/org.apache.xbean/xbean-reflect/3.7, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.assertj/assertj-core/3.26.0, Apache-2.0, approved, #14886
Expand Down Expand Up @@ -583,7 +583,7 @@
maven/mavencentral/org.eclipse.jetty/jetty-xml/11.0.22, EPL-2.0 OR Apache-2.0, approved, rt.jetty
maven/mavencentral/org.eclipse.parsson/parsson/1.1.6, EPL-2.0, approved, ee4j.parsson
maven/mavencentral/org.flywaydb/flyway-core/10.16.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.flywaydb/flyway-database-postgresql/10.16.0, NOASSERTION, restricted, clearlydefined
maven/mavencentral/org.flywaydb/flyway-database-postgresql/10.16.0, Apache-2.0, approved, #15746
maven/mavencentral/org.glassfish.hk2.external/aopalliance-repackaged/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish
maven/mavencentral/org.glassfish.hk2/hk2-api/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish
maven/mavencentral/org.glassfish.hk2/hk2-locator/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish
Expand Down Expand Up @@ -668,7 +668,7 @@
maven/mavencentral/org.testcontainers/postgresql/1.19.8, MIT, approved, #10350
maven/mavencentral/org.testcontainers/postgresql/1.20.0, MIT, approved, clearlydefined
maven/mavencentral/org.testcontainers/testcontainers/1.19.8, MIT, approved, #15203
maven/mavencentral/org.testcontainers/testcontainers/1.20.0, MIT, restricted, clearlydefined
maven/mavencentral/org.testcontainers/testcontainers/1.20.0, None, restricted, #15747
maven/mavencentral/org.xmlresolver/xmlresolver/5.2.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.xmlunit/xmlunit-core/2.9.1, Apache-2.0, approved, #6272
maven/mavencentral/org.xmlunit/xmlunit-placeholders/2.9.1, Apache-2.0, approved, clearlydefined
Expand Down
23 changes: 16 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ allprojects {
// 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()
) {
if (project.plugins.hasPlugin("com.github.johnrengelman.shadow")) {
val buildDir = project.layout.buildDirectory.get().asFile

val agentFile = buildDir.resolve("opentelemetry-javaagent.jar")
Expand Down Expand Up @@ -173,20 +171,30 @@ subprojects {
}
}

val shadowJarTask = tasks.named(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME).get()

// this task copies some legal docs into the build folder, so we can easily copy them into the docker images
val copyLegalDocs = tasks.create("copyLegalDocs", Copy::class) {
from(project.rootProject.projectDir)
into("${buildDir}/legal")
include("SECURITY.md", "NOTICE.md", "DEPENDENCIES", "LICENSE")
dependsOn(tasks.named(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME))
dependsOn(shadowJarTask)
}

val copyDockerfile = tasks.create("copyDockerfile", Copy::class) {
from(rootProject.projectDir.toPath().resolve("resources"))
into(project.layout.buildDirectory)
include("Dockerfile")
}
shadowJarTask.dependsOn(copyDockerfile)

//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) {
dockerFile.set(project.layout.buildDirectory.asFile.get().toPath().resolve("Dockerfile").toFile())

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:
Expand All @@ -197,9 +205,10 @@ subprojects {
buildArgs.put("ADDITIONAL_FILES", "build/legal/*")
inputDir.set(file(dockerContextDir))
}

// make sure always runs after "dockerize" and after "copyOtel"
dockerTask
.dependsOn(tasks.named(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME))
.dependsOn(shadowJarTask)
.dependsOn(downloadOtel)
.dependsOn(copyLegalDocs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Eclipse Tractus-X product(s) installed within the image:

- GitHub: <https://github.com/eclipse-tractusx/tractusx-edc>
- Project home: <https://projects.eclipse.org/projects/automotive.tractusx>
- Dockerfile: <https://github.com/eclipse-tractusx/tractusx-edc/blob/main/edc-controlplane/edc-controlplane-postgresql-azure-vault/src/main/docker/Dockerfile>
- Dockerfile: <https://github.com/eclipse-tractusx/tractusx-edc/blob/main/Dockerfile>
- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/tractusx-edc/blob/main/LICENSE)

## Used base image
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Eclipse Tractus-X product(s) installed within the image:

- GitHub: <https://github.com/eclipse-tractusx/tractusx-edc>
- Project home: <https://projects.eclipse.org/projects/automotive.tractusx>
- Dockerfile: <https://github.com/eclipse-tractusx/tractusx-edc/blob/main/edc-controlplane/edc-controlplane-postgresql-hashicorp-vault/src/main/docker/Dockerfile>
- Dockerfile: <https://github.com/eclipse-tractusx/tractusx-edc/blob/main/Dockerfile>
- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/tractusx-edc/blob/main/LICENSE)

## Used base image
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion edc-controlplane/edc-runtime-memory/notice.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Eclipse Tractus-X product(s) installed within the image:

- GitHub: <https://github.com/eclipse-tractusx/tractusx-edc>
- Project home: <https://projects.eclipse.org/projects/automotive.tractusx>
- Dockerfile: <https://github.com/eclipse-tractusx/tractusx-edc/blob/main/edc-controlplane/edc-runtime-memory/src/main/docker/Dockerfile>
- Dockerfile: <https://github.com/eclipse-tractusx/tractusx-edc/blob/main/Dockerfile>
- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/tractusx-edc/blob/main/LICENSE)

## Used base image
Expand Down
Loading
Loading