merge all docker images into one
This commit is contained in:
parent
42de7c3a92
commit
f4ded488ce
|
@ -1,4 +0,0 @@
|
|||
FROM ubuntu:22.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y dnsutils iputils-ping tshark vim
|
|
@ -1,4 +0,0 @@
|
|||
FROM ubuntu:22.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y nsd iputils-ping tshark vim
|
|
@ -1,6 +1,6 @@
|
|||
FROM ubuntu:22.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y unbound iputils-ping tshark vim
|
||||
apt-get install -y dnsutils unbound nsd iputils-ping tshark vim
|
||||
|
||||
COPY ./files/etc/unbound/unbound.conf /etc/unbound/unbound.conf
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::sync::atomic::AtomicUsize;
|
|||
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
use crate::{Image, Result};
|
||||
use crate::Result;
|
||||
|
||||
pub struct Container {
|
||||
id: String,
|
||||
|
@ -16,15 +16,17 @@ pub struct Container {
|
|||
|
||||
impl Container {
|
||||
/// Starts the container in a "parked" state
|
||||
pub fn run(image: Image) -> Result<Self> {
|
||||
pub fn run() -> Result<Self> {
|
||||
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
let image_tag = format!("dnssec-tests-{image}");
|
||||
// TODO configurable: hickory; bind
|
||||
let binary = "unbound";
|
||||
let image_tag = format!("dnssec-tests-{binary}");
|
||||
|
||||
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let dockerfile_path = manifest_dir
|
||||
.join("docker")
|
||||
.join(format!("{image}.Dockerfile"));
|
||||
.join(format!("{binary}.Dockerfile"));
|
||||
let docker_dir_path = manifest_dir.join("docker");
|
||||
dbg!(&image_tag);
|
||||
|
||||
|
@ -44,7 +46,7 @@ impl Container {
|
|||
let mut command = Command::new("docker");
|
||||
let pid = process::id();
|
||||
let container_name = format!(
|
||||
"{image}-{pid}-{}",
|
||||
"{binary}-{pid}-{}",
|
||||
COUNT.fetch_add(1, atomic::Ordering::Relaxed)
|
||||
);
|
||||
command.args(&["run", "--rm", "--detach", "--name", &container_name]);
|
||||
|
@ -156,7 +158,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn run_works() -> Result<()> {
|
||||
let container = Container::run(Image::Client)?;
|
||||
let container = Container::run()?;
|
||||
|
||||
let output = container.exec(&["true"])?;
|
||||
assert!(output.status.success());
|
||||
|
@ -166,7 +168,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn ip_addr_works() -> Result<()> {
|
||||
let container = Container::run(Image::Client)?;
|
||||
let container = Container::run()?;
|
||||
|
||||
let ip_addr = container.ip_addr()?;
|
||||
assert!(ip_addr.parse::<Ipv4Addr>().is_ok());
|
||||
|
@ -176,7 +178,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn cp_works() -> Result<()> {
|
||||
let container = Container::run(Image::Client)?;
|
||||
let container = Container::run()?;
|
||||
|
||||
let path = "/tmp/somefile";
|
||||
let contents = "hello";
|
||||
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -23,20 +23,3 @@ impl Domain<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Image {
|
||||
Nsd, // for ROOT, TLD, DOMAIN
|
||||
Unbound,
|
||||
Client,
|
||||
}
|
||||
|
||||
impl fmt::Display for Image {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let name = match self {
|
||||
Image::Nsd => "nsd",
|
||||
Image::Unbound => "unbound",
|
||||
Image::Client => "client",
|
||||
};
|
||||
f.write_str(name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::process::Child;
|
|||
|
||||
use minijinja::{context, Environment};
|
||||
|
||||
use crate::{container::Container, Domain, Image, Result, CHMOD_RW_EVERYONE};
|
||||
use crate::{container::Container, Domain, Result, CHMOD_RW_EVERYONE};
|
||||
|
||||
pub struct NsdContainer {
|
||||
child: Child,
|
||||
|
@ -11,7 +11,7 @@ pub struct NsdContainer {
|
|||
|
||||
impl NsdContainer {
|
||||
pub fn start(domain: Domain) -> Result<Self> {
|
||||
let container = Container::run(Image::Nsd)?;
|
||||
let container = Container::run()?;
|
||||
|
||||
container.exec(&["mkdir", "-p", "/etc/nsd/zones"])?;
|
||||
let zone_path = "/etc/nsd/zones/main.zone";
|
||||
|
@ -86,7 +86,7 @@ mod tests {
|
|||
let tld_ns = NsdContainer::start(Domain::Tld { domain: "com." })?;
|
||||
let ip_addr = tld_ns.ip_addr()?;
|
||||
|
||||
let client = Container::run(Image::Client)?;
|
||||
let client = Container::run()?;
|
||||
let output = client.exec(&["dig", &format!("@{ip_addr}"), "SOA", "com."])?;
|
||||
|
||||
assert!(output.status.success());
|
||||
|
@ -102,7 +102,7 @@ mod tests {
|
|||
let root_ns = NsdContainer::start(Domain::Root)?;
|
||||
let ip_addr = root_ns.ip_addr()?;
|
||||
|
||||
let client = Container::run(Image::Client)?;
|
||||
let client = Container::run()?;
|
||||
let output = client.exec(&["dig", &format!("@{ip_addr}"), "SOA", "."])?;
|
||||
|
||||
assert!(output.status.success());
|
||||
|
|
Loading…
Reference in New Issue
Block a user