-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from fussybeaver/ND-disable-named-pipes
Disable named pipes, upgrade tokio to 1.0
- Loading branch information
Showing
25 changed files
with
296 additions
and
428 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
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,44 @@ | ||
//! Removes old docker containers, images, volumes and networks | ||
|
||
use bollard::{container::PruneContainersOptions, image::PruneImagesOptions, network::PruneNetworksOptions, volume::PruneVolumesOptions}; | ||
use bollard::Docker; | ||
use chrono::{Duration, Utc}; | ||
|
||
use std::collections::HashMap; | ||
|
||
const THRESHOLD_DAYS: i64 = 90; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> { | ||
let docker = Docker::connect_with_unix_defaults()?; | ||
|
||
let date = Utc::now() - Duration::days(THRESHOLD_DAYS); | ||
let timestamp = &date.timestamp().to_string()[..]; | ||
|
||
let mut prune_filters = HashMap::new(); | ||
prune_filters.insert("until", vec![timestamp]); | ||
|
||
let prune = docker.prune_containers(Some(PruneContainersOptions { | ||
filters: prune_filters.clone() | ||
})).await?; | ||
|
||
println!("{:?}", prune); | ||
|
||
let prune = docker.prune_images(Some(PruneImagesOptions { | ||
filters: prune_filters.clone() | ||
})).await?; | ||
|
||
println!("{:?}", prune); | ||
|
||
let prune = docker.prune_volumes(None::<PruneVolumesOptions<String>>).await?; | ||
|
||
println!("{:?}", prune); | ||
|
||
let prune = docker.prune_networks(Some(PruneNetworksOptions { | ||
filters: prune_filters.clone() | ||
})).await?; | ||
|
||
println!("{:?}", prune); | ||
|
||
Ok(()) | ||
} |
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,36 @@ | ||
//! Post a dockerfile | ||
//! | ||
//! tar cvf dockerfile.tar Dockerfile | ||
|
||
use bollard::image::BuildImageOptions; | ||
use bollard::Docker; | ||
use futures_util::stream::StreamExt; | ||
use hyper::body::Body; | ||
|
||
use tokio::fs::File; | ||
use tokio_util::codec::{BytesCodec, FramedRead}; | ||
|
||
use std::env::args; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let docker = Docker::connect_with_unix_defaults().unwrap(); | ||
|
||
let image_options = BuildImageOptions { | ||
dockerfile: "Dockerfile", | ||
t: "rust-test", | ||
rm: true, | ||
..Default::default() | ||
}; | ||
|
||
let filename = &args().nth(1).expect("needs first argument"); | ||
let archive = File::open(filename).await.expect("could not open file"); | ||
let stream = FramedRead::new(archive, BytesCodec::new()); | ||
let body = Body::wrap_stream(stream); | ||
|
||
let mut image_build_stream = docker.build_image(image_options, None, Some(body)); | ||
|
||
while let Some(msg) = image_build_stream.next().await { | ||
println!("Message: {:?}", msg); | ||
} | ||
} |
Oops, something went wrong.