Skip to content

Commit

Permalink
Merge branch 'develop' into anchor-809-6
Browse files Browse the repository at this point in the history
  • Loading branch information
JiahuiWho authored Nov 27, 2024
2 parents 27539a0 + 9eeedb8 commit c7a0c8d
Show file tree
Hide file tree
Showing 21 changed files with 194 additions and 134 deletions.
2 changes: 0 additions & 2 deletions .run/Reference Server_ default.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Reference Server: default" type="JetRunConfigurationType" folderName="Run Single Server">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="default" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunKotlinReferenceServer" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ auth-apikey-custody.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: auth-apikey-custody" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="auth-apikey-custody" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ auth-apikey-platform.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: auth-apikey-platform" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="auth-apikey-platform" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ auth-jwt-custody.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: auth-jwt-custody" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="auth-jwt-custody" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ auth-jwt-platform.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: auth-jwt-platform" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="auth-jwt-platform" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ custody.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: custody" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="custody" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
4 changes: 0 additions & 4 deletions .run/Test Profile_ default.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: default" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
Expand Down
44 changes: 21 additions & 23 deletions .run/Test Profile_ deployment.run.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: deployment" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="deployment" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
</ENTRIES>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="false" name="Test Profile: deployment" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="TEST_PROFILE_NAME" value="deployment" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
</ENTRIES>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
3 changes: 0 additions & 3 deletions .run/Test Profile_ host.docker.internal.run.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: host.docker.internal" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name=";KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yamlTEST_PROFILE_NAME=host-docker-internal" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ kafka-sasl-ssl.run.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: kafka-sasl-ssl" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
<env name="TEST_PROFILE_NAME" value="kafka-sasl-ssl" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
Expand Down
2 changes: 0 additions & 2 deletions .run/Test Profile_ rpc.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Profile: rpc" type="JetRunConfigurationType" folderName="Run Test Profile">
<envs>
<env name="app.enableTest" value="true" />
<env name="TEST_PROFILE_NAME" value="rpc" />
<env name="KT_REFERENCE_SERVER_CONFIG" value="service-runner/src/main/resources/config/reference-config.yaml" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunTestProfile" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=gradle:7.6.4-jdk17-alpine
ARG BASE_IMAGE=gradle:8.2.1-jdk17

FROM ${BASE_IMAGE} AS build
WORKDIR /code
Expand Down
90 changes: 90 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
services:
v2-stable-servers:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: dev-servers
image: stellar/anchor-platform:2.11.2
profiles:
- 'v2-stable'
labels:
description: |
Runs all of the Anchor Platform services for the v2 stable release.
To start the services: `docker-compose --profile v2-stable up`
maintainer: "[email protected]"

stable-servers:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: dev-servers
image: stellar/anchor-platform:latest
profiles:
- 'latest'
labels:
description: |
Runs all of the Anchor Platform services for the latest release.
To start the services: `docker-compose --profile latest up`
maintainer: "[email protected]"

local-built-servers:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: dev-servers
image: stellar/anchor-platform:local
profiles:
- 'local'
labels:
description: |
Runs all of the Anchor Platform services from the locally built image.
To start the services: `docker-compose --profile local up`
maintainer: "[email protected]"

platform:
profiles:
- ''
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: platform
depends_on:
- db
- kafka
- reference-server
- sep24-reference-ui

observer:
profiles:
- ''
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: observer
depends_on:
- db
- kafka

reference-server:
profiles:
- ''
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: reference-server
depends_on:
- reference-db

sep24-reference-ui:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: sep24-reference-ui

kafka:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: kafka

db:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: db

reference-db:
extends:
file: service-runner/src/main/resources/common/docker-compose.yaml
service: reference-db
27 changes: 23 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,31 @@ contribute to this project.

## Quickstart

Anchor Platform can be run locally using Docker Compose. This will start an instance of the Anchor Platform and the
Kotlin reference server.
Anchor Platform can be run locally using Docker Compose.

### For version 2.x.x stable release
```shell
docker build --build-arg BASE_IMAGE=gradle:7.6.4-jdk17 -t anchor-platform:local ./
docker compose -f service-runner/src/main/resources/docker-compose.yaml up -d
# In the root directory of the project
docker compose --profile v2-stable up -d
```

### For latest release
```shell
# In the root directory of the project
docker compose --profile latest up -d
```

### For locally built image
To build the Anchor Platform image locally, run the following command in the root directory of the project.
```shell
# In the root directory of the project
docker build -t stellar/anchor-platform:local .
```

Then, run the following command to start the Anchor Platform.
```shell
# In the root directory of the project
docker compose --profile local up -d
```

The [Stellar Demo Wallet](https://demo-wallet.stellar.org) can be used to interact with the Anchor Platform. To get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package org.stellar.reference.di

import com.sksamuel.hoplite.*
import org.stellar.reference.data.Config
import org.stellar.reference.data.LocationConfig

class ConfigContainer(envMap: Map<String, String>?) {
var config: Config = readCfg(envMap)

companion object {
const val KT_REFERENCE_SERVER_CONFIG = "kt.reference.server.config"

@Volatile private var instance: ConfigContainer? = null

fun init(envMap: Map<String, String>?): ConfigContainer {
Expand All @@ -20,20 +20,15 @@ class ConfigContainer(envMap: Map<String, String>?) {
}

private fun readCfg(envMap: Map<String, String>?): Config {
// Load location config
val locationCfg =
ConfigLoaderBuilder.default()
.addPropertySource(PropertySource.environment())
.build()
.loadConfig<LocationConfig>()

val cfgBuilder = ConfigLoaderBuilder.default()
// Add environment variables as a property source.
cfgBuilder.addPropertySource(PropertySource.environment())
envMap?.run { cfgBuilder.addMapSource(this) }
// Add config file as a property source if valid
locationCfg.fold({}, { cfgBuilder.addFileSource(it.ktReferenceServerConfig) })

envMap?.run {
cfgBuilder.addMapSource(this)
if (envMap[KT_REFERENCE_SERVER_CONFIG] != null) {
cfgBuilder.addFileSource(envMap[KT_REFERENCE_SERVER_CONFIG]!!)
}
}
return cfgBuilder.build().loadConfigOrThrow<Config>()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.util.Map;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
Expand All @@ -16,15 +15,15 @@
import org.stellar.reference.wallet.WalletServerStartKt;

public class ServiceRunner {

public static void main(String[] args) {
printBanner();
startServers(args);
}

private static void startServers(String[] args) {
Options options = getOptions();
CommandLineParser parser = new DefaultParser();

try {
CommandLine cmd = parser.parse(options, args);
CommandLine cmd = new DefaultParser().parse(options, args);
boolean anyServerStarted = false;
if (cmd.hasOption("sep-server") || cmd.hasOption("all")) {
startSepServer(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ import org.stellar.anchor.util.StringHelper.isNotEmpty
* @constructor creates a TestConfig instance
*/
class TestConfig {
companion object {
const val TEST_PROFILE_NAME = "TEST_PROFILE_NAME"
}
val env = mutableMapOf<String, String>()
// override test profile name with TEST_PROFILE_NAME system env variable
private val envProfileName = System.getenv("TEST_PROFILE_NAME") ?: null
private val envProfileName = System.getenv(TEST_PROFILE_NAME) ?: null

constructor(testProfileName: String? = null, customize: () -> Unit = {}) {
var profileName = testProfileName
if (System.getenv("TEST_PROFILE_NAME") != null) profileName = System.getenv("TEST_PROFILE_NAME")
if (System.getenv(TEST_PROFILE_NAME) != null) profileName = System.getenv(TEST_PROFILE_NAME)

if (this.envProfileName != null) profileName = this.envProfileName
// starting from the default test.env file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ package org.stellar.anchor.platform.run_profiles

import kotlinx.coroutines.runBlocking
import org.stellar.anchor.platform.*
import org.stellar.reference.di.ConfigContainer.Companion.KT_REFERENCE_SERVER_CONFIG

fun main() = runBlocking {
testProfileExecutor = TestProfileExecutor(TestConfig())
testProfileExecutor =
TestProfileExecutor(
TestConfig().also {
// if KT_REFERENCE_SERVER_CONFIG environment variable is not set, set it to the default
// value: "service-runner/src/main/resources/config/reference-config.yaml"
if (it.env[KT_REFERENCE_SERVER_CONFIG] == null) {
it.env[KT_REFERENCE_SERVER_CONFIG] =
"service-runner/src/main/resources/config/reference-config.yaml"
}
}
)
registerShutdownHook(testProfileExecutor)
testProfileExecutor.start(true) {
it.env[RUN_DOCKER] = "false"
Expand Down
Loading

0 comments on commit c7a0c8d

Please sign in to comment.