Skip to content

Commit

Permalink
set url instead of host
Browse files Browse the repository at this point in the history
  • Loading branch information
joris committed Jan 15, 2024
1 parent 0d8f760 commit 70154cb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AGENT_CONFIG_LOG_FORMAT=json
AGENT_CONFIG_EVENT_STORE=postgres
AGENT_APPLICATION_HOST=my-domain.example.org
AGENT_APPLICATION_URL=https://my-domain.example.org
AGENT_ISSUANCE_CREDENTIAL_NAME="Demo Credential"
AGENT_ISSUANCE_CREDENTIAL_LOGO_URL=https://my-domain.example.org/credential_logo.png
AGENT_STORE_DB_CONNECTION_STRING=postgresql://demo_user:demo_pass@localhost:5432/demo
6 changes: 3 additions & 3 deletions .pipeline/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ spec:
value: "json"
- name: AGENT_CONFIG_EVENT_STORE
value: "postgres"
- name: AGENT_APPLICATION_HOST
value: "dev.impierce.com/unicore"
- name: AGENT_RELATIVE_PATH
- name: AGENT_APPLICATION_URL
value: "https://dev.impierce.com/unicore"
- name: AGENT_APPLICATION_BASE_PATH
value: "unicore"
- name: AGENT_STORE_DB_CONNECTION_STRING
valueFrom:
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions agent_api_rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use std::env;
pub const AGGREGATE_ID: &str = "agg-id-F39A0C";

pub fn app(state: ApplicationState<IssuanceData, IssuanceDataView>) -> Router {
let prefix: Option<String> = env::var_os("AGENT_RELATIVE_PATH").map(|os| {
println!("AGENT_RELATIVE_PATH can't start or end with '/'");
os.into_string().expect("Can't parse AGENT_RELATIVE_PATH")
let prefix: Option<String> = env::var_os("AGENT_APPLICATION_BASE_PATH").map(|os| {
println!("AGENT_APPLICATION_BASE_PATH can't start or end with '/'");
os.into_string().expect("Can't parse AGENT_APPLICATION_BASE_PATH")
});

let path = |suffix: &str| -> String {
Expand Down Expand Up @@ -59,6 +59,7 @@ mod tests {

pub const PRE_AUTHORIZED_CODE: &str = "pre-authorized_code";
pub const SUBJECT_ID: &str = "00000000-0000-0000-0000-000000000000";

lazy_static::lazy_static! {
pub static ref BASE_URL: url::Url = url::Url::parse("https://example.com").unwrap();
}
Expand Down
4 changes: 2 additions & 2 deletions agent_application/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker build -f docker/Dockerfile -t ssi-agent ..

Inside the folder `/agent_application/docker`:

1. _Inside `docker-compose.yml` replace the value `<your-local-ip>` for the environment variable `AGENT_APPLICATION_HOST` with your actual local ip address (such as 192.168.1.234)_
1. _Inside `docker-compose.yml` replace the environment value: `AGENT_APPLICATION_URL` with your actual local ip address (such as http://192.168.1.234:3033)
2. Optionally, add the following environment variables:
- `AGENT_ISSUANCE_CREDENTIAL_NAME`: To set the name of the credentials that will be issued.
- `AGENT_ISSUANCE_CREDENTIAL_LOGO_URL`: To set the URL of the logo that will be used in the credentials.
Expand All @@ -28,7 +28,7 @@ docker compose up -d
---
**NOTE**

When you set the AGENT_RELATIVE_PATH to for example: "unicore"
When you set the AGENT_APPLICATION_BASE_PATH to for example: "unicore"
it will be available at: `http://0.0.0.0:3033/unicore`

---
4 changes: 2 additions & 2 deletions agent_application/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ services:
AGENT_CONFIG_LOG_FORMAT: json
AGENT_CONFIG_EVENT_STORE: postgres
# Relative paths can't start or end with '/'
AGENT_RELATIVE_PATH: "unicore"
AGENT_APPLICATION_HOST: ${AGENT_APPLICATION_HOST:?set it please}
AGENT_APPLICATION_URL: ${AGENT_APPLICATION_URL}
AGENT_APPLICATION_BASE_PATH: "unicore"
AGENT_STORE_DB_CONNECTION_STRING: postgresql://demo_user:demo_pass@cqrs-postgres-db:5432/demo
20 changes: 13 additions & 7 deletions agent_application/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::env;

use agent_api_rest::app;
use agent_issuance::{
queries::SimpleLoggingQuery,
Expand All @@ -7,11 +9,6 @@ use agent_issuance::{
};
use agent_shared::config;
use agent_store::{in_memory, postgres};
use lazy_static::lazy_static;

lazy_static! {
static ref HOST: url::Url = format!("https://{}:3033/", config!("host").unwrap()).parse().unwrap();
}

#[tokio::main]
async fn main() {
Expand All @@ -21,11 +18,20 @@ async fn main() {
};

match config!("log_format").unwrap().as_str() {
"json" => tracing_subscriber::fmt().json().init(),
"json" => tracing_subscriber::fmt().init(),
_ => tracing_subscriber::fmt::init(),
}

initialize(state.clone(), startup_commands(HOST.clone())).await;
let url: url::Url = env::var_os("AGENT_APPLICATION_URL")
.expect("AGENT_APPLICATION_URL is not set")
.into_string()
.unwrap()
.parse()
.unwrap();

tracing::info!("Application url: {:?}", url);

initialize(state.clone(), startup_commands(url)).await;

let server = "0.0.0.0:3033".parse().unwrap();

Expand Down

0 comments on commit 70154cb

Please sign in to comment.