Skip to content

Commit

Permalink
Merge pull request #208 from p2pderivatives/fix/docker-postgres-db
Browse files Browse the repository at this point in the history
Fix postgres db issue in docker compose for oracle
  • Loading branch information
Tibo-lg authored Mar 31, 2024
2 parents a332060 + 6e05eab commit e98f0c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
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"]

0 comments on commit e98f0c4

Please sign in to comment.