Skip to main content

oak_dockerfile/ast/
mod.rs

1#![doc = include_str!("readme.md")]
2use oak_core::Range;
3
4/// Root node of the Dockerfile AST.
5#[derive(Debug, PartialEq, Clone)]
6pub struct DockerfileRoot {
7    /// The list of instructions in the Dockerfile.
8    pub instructions: Vec<Instruction>,
9}
10
11/// A Dockerfile instruction.
12#[derive(Debug, PartialEq, Clone)]
13pub enum Instruction {
14    /// A `FROM` instruction.
15    From {
16        /// The base image.
17        image: String,
18        /// Optional tag for the base image.
19        tag: Option<String>,
20        /// The source range.
21        span: Range<usize>,
22    },
23    /// A `RUN` instruction.
24    Run {
25        /// The command to run.
26        command: String,
27        /// The source range.
28        span: Range<usize>,
29    },
30    /// A `COPY` instruction.
31    Copy {
32        /// Source path.
33        src: String,
34        /// Destination path.
35        dest: String,
36        /// The source range.
37        span: Range<usize>,
38    },
39    /// An `ADD` instruction.
40    Add {
41        /// Source path.
42        src: String,
43        /// Destination path.
44        dest: String,
45        /// The source range.
46        span: Range<usize>,
47    },
48    /// A `WORKDIR` instruction.
49    Workdir {
50        /// The working directory path.
51        path: String,
52        /// The source range.
53        span: Range<usize>,
54    },
55    /// An `EXPOSE` instruction.
56    Expose {
57        /// The port to expose.
58        port: String,
59        /// The source range.
60        span: Range<usize>,
61    },
62    /// An `ENV` instruction.
63    Env {
64        /// The environment variable key.
65        key: String,
66        /// The environment variable value.
67        value: String,
68        /// The source range.
69        span: Range<usize>,
70    },
71    /// A `CMD` instruction.
72    Cmd {
73        /// The command to execute.
74        command: String,
75        /// The source range.
76        span: Range<usize>,
77    },
78    /// An `ENTRYPOINT` instruction.
79    Entrypoint {
80        /// The entrypoint command.
81        command: String,
82        /// The source range.
83        span: Range<usize>,
84    },
85    /// A `VOLUME` instruction.
86    Volume {
87        /// The volume path.
88        path: String,
89        /// The source range.
90        span: Range<usize>,
91    },
92    /// A `USER` instruction.
93    User {
94        /// The username or UID.
95        user: String,
96        /// The source range.
97        span: Range<usize>,
98    },
99    /// A `LABEL` instruction.
100    Label {
101        /// The label key.
102        key: String,
103        /// The label value.
104        value: String,
105        /// The source range.
106        span: Range<usize>,
107    },
108    /// An `ARG` instruction.
109    Arg {
110        /// The argument name.
111        name: String,
112        /// Optional default value.
113        default: Option<String>,
114        /// The source range.
115        span: Range<usize>,
116    },
117    /// An `ONBUILD` instruction.
118    Onbuild {
119        /// The nested instruction.
120        instruction: Box<Instruction>,
121        /// The source range.
122        span: Range<usize>,
123    },
124    /// A `STOPSIGNAL` instruction.
125    Stopsignal {
126        /// The signal name or number.
127        signal: String,
128        /// The source range.
129        span: Range<usize>,
130    },
131    /// A `HEALTHCHECK` instruction.
132    Healthcheck {
133        /// The health check command.
134        command: String,
135        /// The source range.
136        span: Range<usize>,
137    },
138    /// A `SHELL` instruction.
139    Shell {
140        /// The shell command.
141        shell: String,
142        /// The source range.
143        span: Range<usize>,
144    },
145}