pub enum Instruction {
Show 16 variants
Run(RunInstruction),
Copy(CopyInstruction),
Add(AddInstruction),
Env(EnvInstruction),
Workdir(String),
Expose(ExposeInstruction),
Label(HashMap<String, String>),
User(String),
Entrypoint(ShellOrExec),
Cmd(ShellOrExec),
Volume(Vec<String>),
Shell(Vec<String>),
Arg(ArgInstruction),
Stopsignal(String),
Healthcheck(HealthcheckInstruction),
Onbuild(Box<Instruction>),
}Expand description
A single Dockerfile instruction
Variants§
Run(RunInstruction)
RUN instruction - executes a command and commits the result as a new layer
Copy(CopyInstruction)
COPY instruction - copies files from build context or previous stage
Add(AddInstruction)
ADD instruction - like COPY but with URL support and auto-extraction
Env(EnvInstruction)
ENV instruction - sets environment variables
Workdir(String)
WORKDIR instruction - sets the working directory
Expose(ExposeInstruction)
EXPOSE instruction - documents which ports the container listens on
Label(HashMap<String, String>)
LABEL instruction - adds metadata to the image
User(String)
USER instruction - sets the user for subsequent instructions
Entrypoint(ShellOrExec)
ENTRYPOINT instruction - configures container as executable
Cmd(ShellOrExec)
CMD instruction - provides defaults for container execution
Volume(Vec<String>)
VOLUME instruction - creates mount points
Shell(Vec<String>)
SHELL instruction - changes the default shell
Arg(ArgInstruction)
ARG instruction - defines build-time variables
Stopsignal(String)
STOPSIGNAL instruction - sets the signal for stopping the container
Healthcheck(HealthcheckInstruction)
HEALTHCHECK instruction - defines how to check container health
Onbuild(Box<Instruction>)
ONBUILD instruction - adds trigger for downstream builds
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Returns the instruction name as it would appear in a Dockerfile
Sourcepub fn creates_layer(&self) -> bool
pub fn creates_layer(&self) -> bool
Returns true if this instruction creates a new layer
Sourcepub fn cache_key(&self) -> String
pub fn cache_key(&self) -> String
Generate a cache key for this instruction.
The key uniquely identifies the instruction and its parameters, enabling cache hit detection when combined with the base layer digest.
§Returns
A 16-character hexadecimal string representing the hash of the instruction.
§Example
use zlayer_builder::dockerfile::Instruction;
use zlayer_builder::dockerfile::RunInstruction;
let run = Instruction::Run(RunInstruction::shell("echo hello"));
let key = run.cache_key();
assert_eq!(key.len(), 16);Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
Source§impl Serialize for Instruction
impl Serialize for Instruction
impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnsafeUnpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more