1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4#[cfg(feature = "build")]
7pub use use_docker_build as build;
8#[cfg(feature = "compose")]
9pub use use_docker_compose as compose;
10#[cfg(feature = "env")]
11pub use use_docker_env as env;
12#[cfg(feature = "healthcheck")]
13pub use use_docker_healthcheck as healthcheck;
14#[cfg(feature = "image")]
15pub use use_docker_image as image;
16#[cfg(feature = "label")]
17pub use use_docker_label as label;
18#[cfg(feature = "network")]
19pub use use_docker_network as network;
20#[cfg(feature = "port")]
21pub use use_docker_port as port;
22#[cfg(feature = "registry")]
23pub use use_docker_registry as registry;
24#[cfg(feature = "tag")]
25pub use use_docker_tag as tag;
26#[cfg(feature = "volume")]
27pub use use_docker_volume as volume;
28#[cfg(feature = "dockerfile")]
29pub use use_dockerfile as dockerfile;
30#[cfg(feature = "dockerignore")]
31pub use use_dockerignore as dockerignore;
32
33pub mod prelude {
35 #[cfg(feature = "build")]
36 pub use use_docker_build::{BuildArg, BuildContext, DockerBuildOptions, DockerPlatform};
37 #[cfg(feature = "compose")]
38 pub use use_docker_compose::{ComposeBuild, ComposeProject, ComposeService};
39 #[cfg(feature = "env")]
40 pub use use_docker_env::{EnvLine, EnvLineKind, EnvVar};
41 #[cfg(feature = "healthcheck")]
42 pub use use_docker_healthcheck::{DurationSpec, HealthcheckCommand, HealthcheckConfig};
43 #[cfg(feature = "image")]
44 pub use use_docker_image::DockerImageReference;
45 #[cfg(feature = "label")]
46 pub use use_docker_label::{DockerLabel, DockerLabelKey};
47 #[cfg(feature = "network")]
48 pub use use_docker_network::DockerNetworkMode;
49 #[cfg(feature = "port")]
50 pub use use_docker_port::{PortMapping, PortNumber, PortProtocol};
51 #[cfg(feature = "registry")]
52 pub use use_docker_registry::{DockerRegistry, DockerRepositoryPath, RegistryImagePath};
53 #[cfg(feature = "tag")]
54 pub use use_docker_tag::DockerTag;
55 #[cfg(feature = "volume")]
56 pub use use_docker_volume::{DockerVolumeMount, MountAccess, VolumeKind};
57 #[cfg(feature = "dockerfile")]
58 pub use use_dockerfile::{DockerfileInstruction, DockerfileInstructionKind};
59 #[cfg(feature = "dockerignore")]
60 pub use use_dockerignore::{DockerIgnorePattern, DockerIgnoreRule, DockerIgnoreScope};
61}
62
63#[cfg(all(test, feature = "full"))]
64mod tests {
65 use super::{compose, dockerfile, env, image, port};
66
67 #[test]
68 fn facade_exposes_docker_primitives() -> Result<(), Box<dyn std::error::Error>> {
69 let reference: image::DockerImageReference = "ghcr.io/rustuse/app:0.1.0".parse()?;
70 let mapping: port::PortMapping = "127.0.0.1:8080:80/tcp".parse()?;
71 let variable = env::EnvLine::parse("RUST_LOG=info")?;
72 let service = compose::ComposeService::new("web")
73 .with_image(reference.as_str())
74 .with_port(mapping.to_string());
75 let instruction = dockerfile::DockerfileInstruction::run("cargo test");
76
77 assert_eq!(reference.registry(), Some("ghcr.io"));
78 assert_eq!(variable.key(), Some("RUST_LOG"));
79 assert_eq!(service.name(), "web");
80 assert_eq!(instruction.to_string(), "RUN cargo test");
81 Ok(())
82 }
83}