-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3679dfa
commit 0d9a249
Showing
16 changed files
with
233 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
RUN_MODE=development | ||
APP_SUBSCRIBED_RELAYS=ws://nostr-relay:8080 | ||
APP_PROVING_REQ_SUB_ID=askeladd.proving.request | ||
APP_PROVING_RESP_SUB_ID=askeladd.proving.response | ||
|
||
# User's secret key | ||
# DO NOT USE THIS KEY IN PRODUCTION | ||
APP_USER_BECH32_SK=nsec1tsaxyqcxp8atqup4facwp0as52f2c0evj4cxpw6yaqetusu7sg8qqzkr3k | ||
# Prover agent's secret key | ||
# DO NOT USE THIS KEY IN PRODUCTION | ||
APP_PROVER_AGENT_SK=nsec18s6wcqlkglhjmfz3tnjkh0qscf6cqen96ecp5k5k73ktew3l97tstuvy2x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
RUN_MODE=development | ||
APP_SUBSCRIBED_RELAYS=ws://127.0.0.1:8080 | ||
APP_PROVING_REQ_SUB_ID=askeladd.proving.request | ||
APP_PROVING_RESP_SUB_ID=askeladd.proving.response | ||
|
||
# User's secret key | ||
# DO NOT USE THIS KEY IN PRODUCTION | ||
APP_USER_BECH32_SK=nsec1tsaxyqcxp8atqup4facwp0as52f2c0evj4cxpw6yaqetusu7sg8qqzkr3k | ||
# Prover agent's secret key | ||
# DO NOT USE THIS KEY IN PRODUCTION | ||
APP_PROVER_AGENT_SK=nsec18s6wcqlkglhjmfz3tnjkh0qscf6cqen96ecp5k5k73ktew3l97tstuvy2x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,7 @@ Cargo.lock | |
/target | ||
|
||
# Ignore macos specific files | ||
.DS_Store | ||
.DS_Store | ||
|
||
# Ignore .env files | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM rust:1.67-alpine AS builder | ||
WORKDIR /usr/src/askeladd | ||
RUN apk add --no-cache musl-dev | ||
COPY . . | ||
RUN cargo build --release | ||
|
||
FROM alpine:3.14 | ||
RUN apk add --no-cache libgcc wget | ||
COPY --from=builder /usr/src/askeladd/target/release/prover_agent /usr/local/bin/prover_agent | ||
COPY --from=builder /usr/src/askeladd/target/release/user_cli /usr/local/bin/user_cli | ||
COPY --from=builder /usr/src/askeladd/config /config | ||
COPY --from=builder /usr/src/askeladd/.env.docker /.env | ||
WORKDIR /usr/src/askeladd | ||
ENV RUST_LOG=info | ||
CMD ["prover_agent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
subscribed_relays = ["ws://127.0.0.1:8080"] | ||
proving_req_sub_id = "askeladd.proving.request" | ||
proving_resp_sub_id = "askeladd.proving.response" | ||
user_bech32_sk = "nsec1tsaxyqcxp8atqup4facwp0as52f2c0evj4cxpw6yaqetusu7sg8qqzkr3k" | ||
prover_agent_sk = "nsec18s6wcqlkglhjmfz3tnjkh0qscf6cqen96ecp5k5k73ktew3l97tstuvy2x" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::env; | ||
|
||
use config::{Config, ConfigError, Environment, File}; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(untagged)] | ||
enum StringOrVec { | ||
String(String), | ||
Vec(Vec<String>), | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Settings { | ||
#[serde(deserialize_with = "deserialize_subscribed_relays")] | ||
pub subscribed_relays: Vec<String>, | ||
pub proving_req_sub_id: String, | ||
pub proving_resp_sub_id: String, | ||
pub user_bech32_sk: String, | ||
pub prover_agent_sk: String, | ||
} | ||
|
||
fn deserialize_subscribed_relays<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
let value = StringOrVec::deserialize(deserializer)?; | ||
Ok(match value { | ||
StringOrVec::String(s) => vec![s], | ||
StringOrVec::Vec(v) => v, | ||
}) | ||
} | ||
|
||
impl Settings { | ||
pub fn new() -> Result<Self, ConfigError> { | ||
let run_mode = env::var("RUN_MODE").unwrap_or_else(|_| "development".into()); | ||
|
||
let s = Config::builder() | ||
// Start off by merging in the "default" configuration file | ||
.add_source(File::with_name("config/default")) | ||
// Add in the current environment file | ||
// Default to 'development' env | ||
// Note that this file is _optional_ | ||
.add_source(File::with_name(&format!("config/{}", run_mode)).required(false)) | ||
// Add in a local configuration file | ||
// This file shouldn't be checked in to git | ||
.add_source(File::with_name("config/local").required(false)) | ||
// Add in settings from the environment (with a prefix of APP) | ||
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key | ||
.add_source(Environment::with_prefix("APP")) | ||
.build()?; | ||
|
||
// You can deserialize (and thus freeze) the entire configuration as | ||
s.try_deserialize() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod data_fixture; | ||
pub mod config; | ||
pub mod prover_service; | ||
pub mod types; | ||
pub mod verifier_service; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: "3.8" | ||
|
||
services: | ||
nostr-relay: | ||
image: scsibug/nostr-rs-relay:latest | ||
ports: | ||
- "8080:8080" | ||
|
||
prover-agent: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
command: prover_agent | ||
env_file: .env | ||
volumes: | ||
- ./config:/usr/src/askeladd/config | ||
depends_on: | ||
nostr-relay: | ||
condition: service_started | ||
environment: | ||
- APP_SUBSCRIBED_RELAYS=ws://nostr-relay:8080 | ||
|
||
user-cli: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
command: user_cli | ||
env_file: .env | ||
volumes: | ||
- ./config:/usr/src/askeladd/config | ||
depends_on: | ||
nostr-relay: | ||
condition: service_started | ||
prover-agent: | ||
condition: service_started | ||
environment: | ||
- APP_SUBSCRIBED_RELAYS=ws://nostr-relay:8080 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Function to stop all containers and exit | ||
cleanup() { | ||
echo "Stopping all containers..." | ||
docker-compose down | ||
exit 0 | ||
} | ||
|
||
# Trap Ctrl+C and call cleanup | ||
trap cleanup INT | ||
|
||
# Ensure we're in the correct directory | ||
cd "$(dirname "$0")" | ||
|
||
# Build and start the containers | ||
#docker-compose up --build -d | ||
docker-compose up -d | ||
|
||
# Wait for services to be ready | ||
echo "Waiting for services to be ready..." | ||
docker-compose run --rm user-cli /bin/sh -c "until wget -q --spider http://nostr-relay:8080; do sleep 1; done" | ||
|
||
# Function to display logs with a specific color | ||
show_logs() { | ||
local container_name=$1 | ||
local color=$2 | ||
docker-compose logs -f "$container_name" | sed "s/^/$(tput setaf $color)[$container_name] /" | ||
} | ||
|
||
# Run log displays in the background | ||
show_logs nostr-relay 1 & | ||
show_logs prover-agent 2 & | ||
show_logs user-cli 3 & | ||
|
||
# Wait for user input to stop | ||
echo "Demo is running. Press Enter to stop..." | ||
read | ||
|
||
# Cleanup and exit | ||
cleanup |