Skip to contents

Adds a raw line to a `dockerfile“ at a specified position. This is a lower-level function typically used internally by higher-level functions.

Usage

dfm_add_line(dockerfile, line, after = NULL)

Arguments

dockerfile

A dockerfile object

line

Line to add (raw text)

after

Position after which to add the line (default: end of file)

Value

An updated dockerfile object with the new line added

Details

Unlike the instruction-specific functions (dfi_*), this function adds raw text without any formatting or validation. It's useful for adding comments or custom instructions not covered by the built-in functions.

See also

dfm_remove_line() for removing a line & dfm_replace_line() for replacing a line

Other dockerfile modification functions: dfm_group_similar(), dfm_move_line(), dfm_remove_line(), dfm_replace_line(), dfm_sort_by_instruction()

Examples

df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0")
  
# Add a comment after the FROM instruction
df <- dfm_add_line(df, "# This is a comment", after = 1)