Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix postgres db issue in docker compose for oracle #208

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ services:
- ./testconfig/oracle/certs/oracle:/key

oracle-db:
image: "postgres:12.2"
image: oracledb:latest
build:
context: .
dockerfile: ./testconfig/oracle/oracledb.dockerfile
profiles: [oracle]
command: |
-c log_statement=all
Expand All @@ -62,7 +65,6 @@ services:
- POSTGRES_DB=db
volumes:
- oracle-db-data:/var/lib/postgresql/data/ # persist data even if container shuts down
- ./testconfig/oracle/certs/db:/certs


volumes:
Expand Down
13 changes: 9 additions & 4 deletions p2pd-oracle-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate reqwest;
extern crate secp256k1_zkp;
extern crate serde;

use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
use chrono::{DateTime, SecondsFormat, Utc};
use dlc_manager::error::Error as DlcManagerError;
use dlc_manager::Oracle;
use dlc_messages::oracle_msgs::{OracleAnnouncement, OracleAttestation};
Expand Down Expand Up @@ -130,9 +130,14 @@ fn parse_event_id(event_id: &str) -> Result<(String, DateTime<Utc>), DlcManagerE
let timestamp: i64 = timestamp_str
.parse()
.map_err(|_| DlcManagerError::OracleError("Invalid timestamp format".to_string()))?;
let naive_date_time = NaiveDateTime::from_timestamp_opt(timestamp, 0).ok_or_else(|| {
DlcManagerError::InvalidParameters(format!("Invalid timestamp {} in event id", timestamp))
})?;
let naive_date_time = DateTime::from_timestamp(timestamp, 0)
.ok_or_else(|| {
DlcManagerError::InvalidParameters(format!(
"Invalid timestamp {} in event id",
timestamp
))
})?
.naive_utc();
let date_time = DateTime::from_naive_utc_and_offset(naive_date_time, Utc);
Ok((asset_id.to_string(), date_time))
}
Expand Down
9 changes: 9 additions & 0 deletions testconfig/oracle/oracledb.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM postgres:16.2

RUN mkdir certs
COPY ./testconfig/oracle/certs/db/db.crt /certs/
COPY ./testconfig/oracle/certs/db/db.key /certs/
RUN chmod 600 /certs/db.key
RUN chown postgres /certs/db.key

CMD ["postgres"]
Loading