-
Notifications
You must be signed in to change notification settings - Fork 5
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
8ea984a
commit 0ed2831
Showing
9 changed files
with
292 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,58 @@ | ||
use testcontainers::clients::Cli; | ||
use testcontainers::core::WaitFor; | ||
use testcontainers::Container; | ||
use testcontainers::GenericImage; | ||
use testcontainers::RunnableImage; | ||
use testcontainers_modules::postgres::Postgres as PostgresImage; | ||
|
||
#[derive(Default)] | ||
pub struct Docker { | ||
cli: Cli, | ||
} | ||
|
||
impl Docker { | ||
/// Starts PostgreSQL container for local development. | ||
#[must_use] | ||
pub fn start_postgres(&self) -> Container<'_, PostgresImage> { | ||
tracing::info!("starting postgres container"); | ||
|
||
let image = RunnableImage::from(PostgresImage::default().with_user("postgres").with_password("123").with_db_name("stratus")) | ||
.with_mapped_port((5432, 5432)) | ||
.with_volume(("./static/schema/001-init.sql", "/docker-entrypoint-initdb.d/001-schema.sql")) | ||
.with_volume(("./static/schema/002-schema-external-rpc.sql", "/docker-entrypoint-initdb.d/002-schema.sql")) | ||
.with_tag("16.2"); | ||
|
||
self.cli.run(image) | ||
} | ||
|
||
/// Starts Prometheus container for local development. | ||
#[must_use] | ||
pub fn start_prometheus(&self) -> Container<'_, GenericImage> { | ||
tracing::info!("starting prometheus container"); | ||
|
||
let prometheus_image = GenericImage::new("prom/prometheus", "v2.50.1").with_wait_for(WaitFor::StdErrMessage { | ||
message: "Starting rule manager...".to_string(), | ||
}); | ||
let prometheus_args: Vec<String> = vec![ | ||
"--config.file=/etc/prometheus/prometheus.yaml".into(), | ||
"--storage.tsdb.path=/prometheus".into(), | ||
"--log.level=debug".into(), | ||
]; | ||
|
||
let image = RunnableImage::from((prometheus_image, prometheus_args)) | ||
.with_mapped_port((9090, 9090)) | ||
.with_volume(("./static/prometheus.yaml", "/etc/prometheus/prometheus.yaml")); | ||
|
||
self.cli.run(image) | ||
} | ||
|
||
/// Returns PostgreSQL container URL connection. | ||
pub fn postgres_connection_url(&self) -> &'static str { | ||
"postgres://postgres:123@localhost:5432/stratus" | ||
} | ||
|
||
/// Returns Prometheus container API URL. | ||
pub fn prometheus_api_url(&self) -> &'static str { | ||
"http://localhost:9090/api/v1/query" | ||
} | ||
} |
Oops, something went wrong.