Skip to content
1 change: 0 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ buildJavaProject(
shouldPublishJars: false,
shouldPublishDockerImages: true,
dockerfileDir: './docker',
//dockerfileFilename: "Dockerfile-local",
buildContext: '.',
//dockerImageRepositoryName: '',
preProductionVisibility: 'docker.io',
Expand Down
43 changes: 20 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,28 @@ plugins {
id 'maven-publish'
}

group = 'com.iexec.blockchain'
sourceCompatibility = 11
targetCompatibility = 11

ext {
openFeignVersion = '11.6'
gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
}

if (gitBranch != 'main' && gitBranch != 'master' && ! (gitBranch ==~ '(release|hotfix|support)/.*')) {
version += '-NEXT-SNAPSHOT'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenLocal()
mavenCentral()
// iExec
maven {
url "https://nexus.iex.ec/repository/maven-public/"
allprojects {
group = 'com.iexec.blockchain'
sourceCompatibility = 11
targetCompatibility = 11
if (gitBranch != 'main' && gitBranch != 'master' && !(gitBranch ==~ '(release|hotfix|support)/.*')) {
version += '-NEXT-SNAPSHOT'
}
maven {
url "https://jitpack.io"
repositories {
mavenLocal()
mavenCentral()
// iExec
maven {
url "https://nexus.iex.ec/repository/maven-public/"
}
maven {
url "https://jitpack.io"
}
}
}

Expand Down Expand Up @@ -73,6 +67,9 @@ dependencies {
implementation "io.github.openfeign:feign-core:$openFeignVersion"
implementation "io.github.openfeign:feign-jackson:$openFeignVersion"
implementation "io.github.openfeign:feign-slf4j:$openFeignVersion"

// integration tests
implementation project(':iexec-blockchain-adapter-api-library')
}

springBoot {
Expand Down Expand Up @@ -156,6 +153,6 @@ ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remo
task buildImage(type: Exec) {
group 'Build'
description 'Builds an OCI image from a Dockerfile.'
commandLine("sh", "-c", "docker build -f docker/Dockerfile-local --build-arg spring_boot_jar=$bootJarPath -t $ociImageName:$gitShortCommit ."
commandLine("sh", "-c", "docker build -f docker/Dockerfile --build-arg spring_boot_jar=$bootJarPath -t $ociImageName:$gitShortCommit ."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No palantir docker extension anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was removed to converge between all repositories and to be able to quickly copy/paste the docker build command if needed.

+ " && docker tag $ociImageName:$gitShortCommit $ociImageName:dev")
}
23 changes: 5 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
ARG HOME=/home
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ARG spring_boot_jar
# Build app container
FROM openjdk:11.0.3-jre-slim

# Build jar
FROM gradle:6.8.3-jdk11 as gradle-builder
ARG HOME
WORKDIR $HOME
ARG spring_boot_jar

RUN test -n "$spring_boot_jar"
COPY build.gradle gradle.properties settings.gradle ./
COPY src/ src/
RUN gradle build -i --no-daemon

# Build app container
FROM openjdk:11.0.3-jre-slim
ARG HOME
ARG spring_boot_jar
COPY --from=gradle-builder $HOME/$spring_boot_jar app.jar
ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ]
COPY $spring_boot_jar app.jar

# CI/CD version
## git clone, then cd into
## docker image build -f docker/Dockerfile .
ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ]
23 changes: 23 additions & 0 deletions docker/Dockerfile-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG HOME=/home
ARG spring_boot_jar

# Build jar
FROM gradle:6.8.3-jdk11 as gradle-builder
ARG HOME
WORKDIR $HOME
ARG spring_boot_jar
RUN test -n "$spring_boot_jar"
COPY build.gradle gradle.properties settings.gradle ./
COPY src/ src/
RUN gradle build -i --no-daemon

# Build app container
FROM openjdk:11.0.3-jre-slim
ARG HOME
ARG spring_boot_jar
COPY --from=gradle-builder $HOME/$spring_boot_jar app.jar
ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ]

# CI/CD version
## git clone, then cd into
## docker image build -f docker/Dockerfile .
10 changes: 0 additions & 10 deletions docker/Dockerfile-local

This file was deleted.

47 changes: 47 additions & 0 deletions iexec-blockchain-adapter-api-library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id 'java-library'
id 'jacoco'
id 'maven-publish'
}

dependencies {
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
}

java {
withJavadocJar()
withSourcesJar()
}

test {
useJUnitPlatform()
}

jacoco {
toolVersion = "0.8.7"
}
// sonarqube code coverage requires jacoco XML report
jacocoTestReport {
reports {
xml.enabled true
}
}
tasks.test.finalizedBy tasks.jacocoTestReport

publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username project.hasProperty("nexusUser")? project.nexusUser: ''
password project.hasProperty("nexusPassword")? project.nexusPassword: ''
}
url = project.hasProperty("nexusUrl")? project.nexusUrl: ''
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2022 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.iexec.blockchain.api;

import com.iexec.blockchain.tool.Status;
import com.iexec.common.chain.ChainDataset;
import com.iexec.common.chain.adapter.args.TaskContributeArgs;
import com.iexec.common.chain.adapter.args.TaskFinalizeArgs;
import com.iexec.common.chain.adapter.args.TaskRevealArgs;
import com.iexec.common.sdk.broker.BrokerOrder;
import feign.Param;
import feign.RequestLine;

/**
* Interface allowing to instantiate a Feign client targeting Blockchain adapter API REST endpoints.
* <p>
* To create the client, call:
* <pre>FeignBuilder.createBuilder(feignLogLevel)
* .target(BlockchainAdapterApiClient.class, blockchainAdapterUrl)</pre>
* @see com.iexec.common.utils.FeignBuilder
*/
public interface BlockchainAdapterApiClient {

//TODO update endpoint
@RequestLine("POST /broker/broker/orders/match")
String matchOrders(BrokerOrder brokerOrder);

@RequestLine("POST /datasets/requests?name={name}&multiAddress={multiAddress}&checksum={checksum}")
String createDataset(@Param("name") String name,
@Param("multiAddress") String multiAddress,
@Param("checksum") String checksum);

@RequestLine("GET /datasets/requests/{requestId}")
String getAddressForCreateDatasetRequest(@Param("requestId") String requestId);

@RequestLine("GET /datasets/requests/{requestId}/status")
Status getStatusForCreateDatasetRequest(@Param("requestId") String requestId);

@RequestLine("GET /datasets?address={address}")
ChainDataset getDatasetByAddress(@Param("address") String address);

@RequestLine("GET /metrics")
String getMetrics();

@RequestLine("POST /tasks/initialize?chainDealId={chainDealId}&taskIndex={taskIndex}")
String requestInitializeTask(@Param("chainDealId") String chainDealId,
@Param("taskIndex") int taskIndex);

@RequestLine("POST /tasks/contribute/{chainTaskId}")
String requestContributeTask(@Param("chainTaskId") String chainTaskId, TaskContributeArgs taskContributeArgs);

@RequestLine("POST /tasks/reveal/{chainTaskId}")
String requestRevealTask(@Param("chainTaskId") String chainTaskId, TaskRevealArgs taskRevealArgs);

@RequestLine("POST /tasks/finalize/{chainTaskId}")
String requestFinalizeTask(@Param("chainTaskId") String chainTaskId, TaskFinalizeArgs taskFinalizeArgs);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.iexec.blockchain.api;

import com.iexec.common.utils.FeignBuilder;
import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor;

public class BlockchainAdapterApiClientBuilder {

private BlockchainAdapterApiClientBuilder() {}

public static BlockchainAdapterApiClient getInstance(Logger.Level logLevel,
String url, String username, String password) {
BasicAuthRequestInterceptor requestInterceptor =
new BasicAuthRequestInterceptor(
username,
password
);
return FeignBuilder.createBuilder(logLevel)
.requestInterceptor(requestInterceptor)
.target(BlockchainAdapterApiClient.class, url);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 IEXEC BLOCKCHAIN TECH
* Copyright 2022 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,10 +17,8 @@
package com.iexec.blockchain.tool;

public enum Status {

RECEIVED,
PROCESSING,
SUCCESS,
FAILURE,

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.iexec.blockchain.api;

import feign.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class BlockchainAdapterApiClientTest {

@Test
void instantiationTest() {
Assertions.assertNotNull(BlockchainAdapterApiClientBuilder
.getInstance(Logger.Level.FULL, "localhost", "username", "password"));
}

}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rootProject.name = 'iexec-blockchain-adapter-api'
include 'iexec-blockchain-adapter-api-library'

This file was deleted.

40 changes: 0 additions & 40 deletions src/itest/java/com/iexec/blockchain/FeignUtils.java

This file was deleted.

Loading