Skip to content

Commit

Permalink
feat: migrate docker image of the agent to Java 21 (#758)
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
Signed-off-by: Anton Baliasnikov <anton.baliasnikov@iohk.io>
Signed-off-by: Pat Losoponkul <pat.losoponkul@iohk.io>
Co-authored-by: Anton Baliasnikov <anton.baliasnikov@iohk.io>
Co-authored-by: Pat Losoponkul <pat.losoponkul@iohk.io>
  • Loading branch information
3 people authored Oct 24, 2023
1 parent 045d829 commit d36dbf0
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 32 deletions.
12 changes: 7 additions & 5 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM openjdk:22-jdk-slim

RUN apt-get update && \
apt-get install --no-install-recommends --yes \
Expand All @@ -8,10 +8,10 @@ RUN apt-get update && \
unzip=6.* \
zip=3.* \
jq=1.* \
python3=3.10.* \
python3-pip=22.* \
python3-setuptools=59.6.* \
python3-wheel=0.37.* \
python3=3.11.* \
python3-pip=23.* \
python3-setuptools=66.* \
python3-wheel=0.38.* \
gnupg=2.2.* \
default-jre=2:1.* \
build-essential=12.* && \
Expand All @@ -23,3 +23,5 @@ RUN apt-get update && \
apt-get install --no-install-recommends --yes \
sbt=1.4.* \
&& rm -rf /var/lib/apt/lists/*

CMD [ "/bin/bash" ]
6 changes: 3 additions & 3 deletions .github/workflows/build-test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: agent-ci-ubuntu-22-jdk-11
IMAGE_NAME: ci-debian-jdk-22

jobs:
build-and-push-image:
Expand Down Expand Up @@ -55,6 +55,6 @@ jobs:
context: .github/docker
push: true
tags: |
"ghcr.io/input-output-hk/${{ env.IMAGE_NAME }}:latest"
"ghcr.io/input-output-hk/${{ env.IMAGE_NAME }}:main"
"ghcr.io/hyperledger-labs/${{ env.IMAGE_NAME }}:latest"
"ghcr.io/hyperledger-labs/${{ env.IMAGE_NAME }}:main"
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: "Build and unit tests for ${{ inputs.component-name }}"
runs-on: self-hosted
container:
image: ghcr.io/input-output-hk/agent-ci-ubuntu-22-jdk-11:0.1.0
image: ghcr.io/hyperledger-labs/ci-debian-jdk-22:0.1.0
volumes:
- /nix:/nix
credentials:
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ lazy val D_Castor = new {
D.circeCore,
D.circeGeneric,
D.circeParser,
prismCrypto,
prismIdentity,
scalaUri
)
Expand Down Expand Up @@ -789,7 +788,8 @@ lazy val prismAgentServer = project
Docker / dockerUsername := Some("input-output-hk"),
Docker / dockerRepository := Some("ghcr.io"),
dockerExposedPorts := Seq(8080, 8085, 8090),
dockerBaseImage := "openjdk:11",
// Official docker image for openjdk 21 with curl and bash
dockerBaseImage := "openjdk:21-jdk",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "io.iohk.atala.agent.server.buildinfo",
Compile / packageDoc / publishArtifact := false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.iohk.atala.mercury.protocol.connection.{ConnectionRequest, ConnectionR
import io.iohk.atala.mercury.protocol.invitation.v2.Invitation

import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.UUID

/** @param id
Expand Down Expand Up @@ -38,7 +39,13 @@ case class ConnectionRecord(
metaRetries: Int,
metaNextRetry: Option[Instant],
metaLastFailure: Option[String]
)
) {
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): ConnectionRecord = copy(
createdAt = createdAt.truncatedTo(unit),
updatedAt = updatedAt.map(_.truncatedTo(unit)),
metaNextRetry = metaNextRetry.map(_.truncatedTo(unit))
)
}

object ConnectionRecord {
enum Role:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import io.iohk.atala.mercury.protocol.connection.{ConnectionRequest, ConnectionR
import io.iohk.atala.mercury.protocol.invitation.v2.Invitation
import io.iohk.atala.shared.models.{WalletAccessContext, WalletId}
import zio.test.*
import zio.test.Assertion.*
import zio.{Cause, Exit, ZIO, ZLayer}

import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.UUID

object ConnectionRepositorySpecSuite {
Expand All @@ -19,7 +21,7 @@ object ConnectionRepositorySpecSuite {

private def connectionRecord = ConnectionRecord(
UUID.randomUUID,
Instant.now,
Instant.now.truncatedTo(ChronoUnit.MICROS),
None,
UUID.randomUUID().toString,
None,
Expand All @@ -34,9 +36,9 @@ object ConnectionRepositorySpecSuite {
None,
None,
maxRetries,
Some(Instant.now),
Some(Instant.now.truncatedTo(ChronoUnit.MICROS)),
None
)
).withTruncatedTimestamp()

private def connectionRequest = ConnectionRequest(
from = DidId("did:prism:aaa"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import zio.*
import java.net.URL
import java.time.Instant
import java.util.UUID
import java.time.temporal.ChronoUnit

final case class EventNotificationConfig(
id: UUID,
walletId: WalletId,
url: URL,
customHeaders: Map[String, String],
createdAt: Instant
)
) {
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): EventNotificationConfig =
copy(createdAt = createdAt.truncatedTo(unit))
}

object EventNotificationConfig {
def apply(walletId: WalletId, url: URL, customHeaders: Map[String, String] = Map.empty): EventNotificationConfig =
Expand All @@ -24,7 +28,7 @@ object EventNotificationConfig {
url = url,
customHeaders = customHeaders,
createdAt = Instant.now
)
).withTruncatedTimestamp()

def applyWallet(url: URL, customHeaders: Map[String, String]): URIO[WalletAccessContext, EventNotificationConfig] =
ZIO.serviceWith[WalletAccessContext](ctx => apply(ctx.walletId, url, customHeaders))
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/local/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PRISM_AGENT_VERSION=1.16.0
PRISM_AGENT_VERSION=1.17.0
PRISM_NODE_VERSION=2.2.1
VAULT_DEV_ROOT_TOKEN_ID=root
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata
import io.iohk.atala.pollux.core.model.IssueCredentialRecord.*

import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.UUID

final case class IssueCredentialRecord(
Expand Down Expand Up @@ -57,7 +58,14 @@ final case class IssueCredentialRecord(
case CredentialFormat.AnonCreds => (IssueCredentialIssuedFormat.Anoncred, data)
}

def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): IssueCredentialRecord =
copy(
createdAt = createdAt.truncatedTo(unit),
updatedAt = updatedAt.map(_.truncatedTo(unit)),
metaNextRetry = metaNextRetry.map(_.truncatedTo(unit)),
)
}

final case class ValidIssuedCredentialRecord(
id: DidCommID,
issuedCredentialRaw: Option[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import io.iohk.atala.mercury.protocol.presentproof.ProposePresentation
import io.iohk.atala.mercury.protocol.presentproof.RequestPresentation
import io.iohk.atala.mercury.protocol.presentproof.Presentation
import io.iohk.atala.mercury.model.DidId

import java.time.Instant
import java.time.temporal.ChronoUnit

final case class PresentationRecord(
id: DidCommID,
Expand All @@ -24,7 +26,14 @@ final case class PresentationRecord(
metaRetries: Int,
metaNextRetry: Option[Instant],
metaLastFailure: Option[String],
)
) {
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): PresentationRecord =
copy(
createdAt = createdAt.truncatedTo(unit),
updatedAt = updatedAt.map(_.truncatedTo(unit)),
metaNextRetry = metaNextRetry.map(_.truncatedTo(unit)),
)
}

object PresentationRecord {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object CredentialRepositorySpecSuite {
metaRetries = maxRetries,
metaNextRetry = Some(Instant.now()),
metaLastFailure = None,
)
).withTruncatedTimestamp()

private def requestCredential = RequestCredential(
from = DidId("did:prism:aaa"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object PresentationRepositorySpecSuite {
metaRetries = maxRetries,
metaNextRetry = Some(Instant.now()),
metaLastFailure = None,
)
).withTruncatedTimestamp()

private def requestPresentation = RequestPresentation(
from = DidId("did:prism:aaa"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.iohk.atala.pollux.core.model.schema.{CorrectnessProof, Definition}
import io.iohk.atala.shared.models.WalletId

import java.time.OffsetDateTime
import java.time.temporal.ChronoUnit
import java.util.UUID

case class CredentialDefinition(
Expand All @@ -29,6 +30,9 @@ case class CredentialDefinition(
walletId: WalletId
) {
lazy val uniqueConstraintKey = author + name + version

def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): CredentialDefinition =
copy(authored = authored.truncatedTo(unit))
}

object CredentialDefinition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.iohk.atala.pollux.core.model.schema.Schema
import io.iohk.atala.shared.models.WalletId

import java.time.OffsetDateTime
import java.time.temporal.ChronoUnit
import java.util.UUID

case class CredentialSchema(
Expand All @@ -24,6 +25,10 @@ case class CredentialSchema(
walletId: WalletId
) {
lazy val uniqueConstraintKey = author + name + version

def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): CredentialSchema =
copy(authored = authored.truncatedTo(unit))

}

object CredentialSchema {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ object VerificationPolicySql extends DoobieContext.Postgres(SnakeCase) {
def getVerificationPolicyConstrains(fk_ids: Seq[UUID]) =
run(
quote(
query[VerificationPolicyConstraint].filter(vpc => liftQuery(fk_ids).contains(vpc.fk_id))
query[VerificationPolicyConstraint]
.filter(vpc => liftQuery(fk_ids).contains(vpc.fk_id))
.sortBy(_.index)(Ord.asc)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object CredentialDefinitionSqlIntegrationSpec extends ZIOSpecDefault with Postgr
signatureType = signatureType,
supportRevocation = supportRevocation,
walletId = walletId
)
).withTruncatedTimestamp()

private val unique = mutable.Set.empty[String]
val credentialDefinitionUnique = for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object CredentialSchemaSqlIntegrationSpec extends ZIOSpecDefault, PostgresTestCo
authored = authored,
tags = tags,
walletId = walletId
)
).withTruncatedTimestamp()

private val unique = mutable.Set.empty[String]
val schemaUnique = for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ object VerificationPolicySqlIntegrationSpec extends ZIOSpecDefault, PostgresTest
name <- name
description <- description
constraints <- Gen
.setOfBounded(min = 1, max = 10)(verificationPolicyConstraint)
.setOfBounded(min = 2, max = 10)(verificationPolicyConstraint)
.map(_.toVector)
} yield VerificationPolicy.make(
name = name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.iohk.atala.pollux.vc.jwt

import com.nimbusds.jose.jwk.{Curve, ECKey}
import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton
import com.nimbusds.jose.jwk.gen.ECKeyGenerator
import com.nimbusds.jose.jwk.{Curve, ECKey}
import io.circe.*
import io.circe.syntax.*
import io.iohk.atala.castor.core.model.did.VerificationRelationship
Expand All @@ -10,10 +11,13 @@ import zio.*
import zio.test.*
import zio.test.Assertion.*

import java.security.Security
import java.time.Instant

object JWTVerificationTest extends ZIOSpecDefault {

Security.insertProviderAt(BouncyCastleProviderSingleton.getInstance(), 2)

case class IssuerWithKey(issuer: Issuer, key: ECKey)

private def createUser(did: DID): IssuerWithKey = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.iohk.atala.shared.models.{WalletAccessContext, WalletId}
import zio.{ULayer, ZLayer}

import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.UUID

trait BaseEntity {
Expand All @@ -12,17 +13,22 @@ trait BaseEntity {

case class Entity(id: UUID, name: String, walletId: UUID, createdAt: Instant, updatedAt: Instant) extends BaseEntity {
def withUpdatedAt(updatedAt: Instant = Instant.now()): Entity = copy(updatedAt = updatedAt)
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): Entity =
copy(createdAt = createdAt.truncatedTo(unit), updatedAt.truncatedTo(unit))
}

object Entity {

val ZeroWalletId: UUID = WalletId.default.toUUID

def apply(id: UUID, name: String, walletId: UUID): Entity =
Entity(id, name, walletId, Instant.now(), Instant.now())
Entity(id, name, walletId, Instant.now(), Instant.now()).withTruncatedTimestamp()

def apply(name: String, walletId: UUID): Entity =
apply(UUID.randomUUID(), name, walletId, Instant.now(), Instant.now())
def apply(name: String): Entity = Entity(UUID.randomUUID(), name, ZeroWalletId, Instant.now(), Instant.now())
apply(UUID.randomUUID(), name, walletId, Instant.now(), Instant.now()).withTruncatedTimestamp()

def apply(name: String): Entity =
Entity(UUID.randomUUID(), name, ZeroWalletId, Instant.now(), Instant.now()).withTruncatedTimestamp()

val Default =
Entity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.iohk.atala.agent.walletapi.model
import io.iohk.atala.shared.models.WalletId

import java.time.Instant
import java.time.temporal.ChronoUnit

final case class Wallet(
id: WalletId,
Expand All @@ -11,6 +12,10 @@ final case class Wallet(
updatedAt: Instant
) {
def withUpdatedAt(updatedAt: Instant): Wallet = copy(updatedAt = updatedAt)
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): Wallet = copy(
createdAt = createdAt.truncatedTo(unit),
updatedAt = updatedAt.truncatedTo(unit)
)
}

object Wallet {
Expand All @@ -21,8 +26,8 @@ object Wallet {
name = name,
createdAt = now,
updatedAt = now,
)
).withTruncatedTimestamp()
}

def apply(name: String): Wallet = apply(name, WalletId.random)
def apply(name: String): Wallet = apply(name, WalletId.random).withTruncatedTimestamp()
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.0
sbt.version=1.9.7

0 comments on commit d36dbf0

Please sign in to comment.