dockerfile-roast 1.4.4

A Dockerfile linter with personality — catches bad practices with snarky, funny error messages
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
# droast documentation

droast is an opinionated Dockerfile linter. It checks security, correctness, reproducibility, image size, cache use, package installation, and runtime behavior.

Use this guide as a quick reference. Every section favors copy-paste examples over long explanations.

## Table of contents

- [Quick start]#quick-start
- [Install]#install
- [What droast understands]#what-droast-understands
- [Command line reference]#command-line-reference
- [Repository discovery]#repository-discovery
- [Configuration]#configuration
- [Copy-paste presets]#copy-paste-presets
- [Control rules and severity]#control-rules-and-severity
- [Output formats]#output-formats
- [CI integration]#ci-integration
- [Local development workflows]#local-development-workflows
- [Docker and container usage]#docker-and-container-usage
- [Wasmer and WASI]#wasmer-and-wasi
- [VS Code]#vs-code
- [Web version]#web-version
- [Rust library]#rust-library
- [Parser API]#parser-api
- [Rule catalog]#rule-catalog
- [Adoption recipes]#adoption-recipes
- [Troubleshooting]#troubleshooting
- [FAQ]#faq

## Quick start

Lint one Dockerfile:

```bash
droast Dockerfile
```

Lint every supported Dockerfile in a repository:

```bash
droast .
```

Lint the current repository:

```bash
droast
```

Show warnings and errors only:

```bash
droast --min-severity warning .
```

Use technical messages without the roast text:

```bash
droast --no-roast .
```

Start with a configuration file:

```bash
droast init
droast .
```

List every rule:

```bash
droast --list-rules
```

Get the rule list as JSON:

```bash
droast --list-rules --format json | jq .
```

## Install

### Install script

Linux and macOS:

```bash
curl -fsL https://ewry.net/droast/install.sh | sh
```

Verify the installation:

```bash
droast --version
droast --help
```

### Homebrew

```bash
brew tap immanuwell/droast https://github.com/immanuwell/homebrew-droast.git
brew install immanuwell/droast/droast
```

Upgrade later:

```bash
brew update
brew upgrade droast
```

### Cargo

Rust users can install from crates.io:

```bash
cargo install dockerfile-roast
```

The installed executable is named `droast`.

Upgrade by reinstalling:

```bash
cargo install dockerfile-roast --force
```

### GitHub release binaries

Download the archive for your platform from [GitHub Releases](https://github.com/immanuwell/dockerfile-roast/releases).

The release includes Linux, macOS, and Windows builds. Put the extracted executable on your `PATH`.

### Container image

```bash
docker pull ghcr.io/immanuwell/droast:1.4.3
```

Use a fixed version in CI. Use `latest` only when automatic upgrades are acceptable.

### Wasmer package

Run droast as a sandboxed WASI command from the [Wasmer Registry](https://wasmer.io/immanuwell/droast):

```bash
wasmer run immanuwell/droast -- --check-dockerignore=false - < Dockerfile
```

No host files are visible unless you explicitly mount them. To lint a repository:

```bash
wasmer run --volume "$PWD:/workspace" immanuwell/droast -- /workspace
```

Use a fixed package version in CI:

```bash
wasmer run --volume "$PWD:/workspace" immanuwell/droast@1.4.3 -- /workspace
```

When the repository uses configuration, pass its mounted path explicitly:

```bash
wasmer run --volume "$PWD:/workspace" immanuwell/droast -- \
  --config /workspace/droast.toml /workspace
```

### Install the VS Code extension

```bash
code --install-extension ImmanuelTikhonov.droast
```

See [VS Code](#vs-code) for settings.

## What droast understands

droast uses a span-aware Dockerfile parser. It is not limited to one instruction per physical line.

### Standard and modern syntax

It understands:

- shell and JSON instruction forms
- line continuations
- quoted and unquoted values
- variable references and modifiers
- multi-stage builds
- parser directives
- BuildKit instruction flags
- heredocs
- Windows paths
- PowerShell commands
- CRLF and UTF-8 input
- malformed syntax with recoverable diagnostics

### Parser directives

Syntax and escape directives are preserved:

```dockerfile
# syntax=docker/dockerfile:1.7
# escape=\

FROM alpine:3.20
```

Windows Dockerfiles can change the escape character:

```dockerfile
# escape=`

FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
SHELL ["powershell", "-Command"]
RUN Write-Host `
    "building"
```

### BuildKit flags

Flags are parsed separately from the command:

```dockerfile
# syntax=docker/dockerfile:1.7
FROM rust:1.79 AS build
WORKDIR /src
RUN --mount=type=cache,target=/usr/local/cargo/registry \
    cargo build --release
```

This includes flags such as:

- `RUN --mount`
- `RUN --network`
- `RUN --security`
- `RUN --device`
- `COPY --from`
- `COPY --chown`
- `COPY --chmod`
- newer flags that use normal BuildKit flag syntax

### Heredocs

Heredoc content is part of the parsed instruction. Shell-oriented rules inspect the executed script too.

```dockerfile
# syntax=docker/dockerfile:1.7
FROM alpine:3.20
RUN <<'SCRIPT'
set -eu
apk add --no-cache curl
curl --fail --location https://example.com/health
SCRIPT
```

Quoted delimiters, tab-stripping heredocs, multiple heredocs, and file descriptors are represented by the parser.

### Exact locations and syntax errors

Instructions, flags, words, variables, heredocs, and diagnostics carry source spans. CLI findings use source line numbers. Invalid Dockerfile syntax is reported by `DF071` when parsing can continue safely.

## Command line reference

```text
droast [OPTIONS] [FILE]... [COMMAND]
```

### Inputs

Pass files, directories, or both:

```bash
droast Dockerfile services/api/Dockerfile
droast services/
droast . Dockerfile.release
```

Quoted glob patterns are also supported:

```bash
droast 'services/*/Dockerfile'
droast 'images/*.Dockerfile'
```

With no input, droast discovers supported files from the current directory:

```bash
droast
```

Lint standard input:

```bash
printf 'FROM alpine:latest\n' | droast -
```

### Options

| Option | Purpose |
|---|---|
| `--config PATH` | Load an explicit TOML configuration |
| `--preset NAME` | Apply `minimal`, `security`, `performance`, `production`, or `strict` |
| `--category NAMES` | Run comma-separated rule categories |
| `--skip-category NAMES` | Skip comma-separated rule categories |
| `-f, --format FORMAT` | Select `terminal`, `json`, `github`, `compact`, or `sarif` |
| `-s, --min-severity LEVEL` | Select `info`, `warning`, or `error` |
| `--skip IDS` | Skip comma-separated rule IDs |
| `--only IDS` | Run only comma-separated rule IDs |
| `--no-roast` | Show technical messages only |
| `--check-dockerignore BOOL` | Enable or disable effective `.dockerignore` checks |
| `--no-fail` | Always exit successfully after linting |
| `--list-rules` | Print the available rules |
| `-h, --help` | Print help |
| `-V, --version` | Print the version |

### Commands

Create `droast.toml` in the current directory:

```bash
droast init
```

Generate shell completion output:

```bash
droast completion bash
droast completion zsh
droast completion fish
```

Example for Bash:

```bash
mkdir -p ~/.local/share/bash-completion/completions
droast completion bash > ~/.local/share/bash-completion/completions/droast
```

Example for Fish:

```fish
droast completion fish > ~/.config/fish/completions/droast.fish
```

### Exit status

| Code | Meaning |
|---|---|
| `0` | No error-severity findings, or `--no-fail` was used |
| `1` | At least one error-severity finding or an execution failure occurred |

Warnings alone do not produce exit code `1`. Use output review or a chosen rule set when warnings must block a workflow.

## Repository discovery

`droast .` recursively discovers:

- `Dockerfile`
- `Dockerfile.*`
- `*.Dockerfile`
- `Containerfile`
- `Containerfile.*`
- Dockerfiles referenced by Compose files
- Dockerfiles referenced by Bake HCL or JSON files

Duplicate references are linted once.

### Compose awareness

Given:

```yaml
services:
  api:
    build:
      context: ./services/api
      dockerfile: Dockerfile.production
  worker:
    build: ./services/worker
```

Running this from the repository root:

```bash
droast .
```

resolves both build contexts and both Dockerfiles. Compose `.env` values are used for supported path interpolation.

### Bake awareness

Given `docker-bake.hcl`:

```hcl
variable "SERVICE" {
  default = "api"
}

target "base" {
  context = "./services/${SERVICE}"
}

target "release" {
  inherits = ["base"]
  dockerfile = "Dockerfile.release"
}
```

droast resolves variables, inherited targets, local build contexts, and Dockerfile paths.

Remote Compose or Bake contexts are not downloaded. droast reports local files it can resolve.

### Repository ignore rules

Recursive discovery respects repository ignore rules so generated or vendored trees are not scanned accidentally. Explicitly requested Dockerfiles are still handled as direct inputs.

### Effective `.dockerignore`

`DF033` checks the ignore file that Docker would use for each build context.

For this build:

```bash
docker build -f docker/release.Dockerfile .
```

droast checks in this order:

1. `docker/release.Dockerfile.dockerignore`
2. `.dockerignore` in the build context

A Dockerfile-specific ignore file takes precedence. Missing, empty, comment-only, and negation-only files are considered ineffective.

Recommended starting point:

```dockerignore
.git
.env
.env.*
node_modules
target
dist
coverage
*.log
```

Disable the check for an unusual workflow:

```bash
droast --check-dockerignore false .
```

## Configuration

Configuration is optional. The file name is `droast.toml`.

### Complete example

```toml
preset = "production"
no-roast = true

require-suppression-reason = true
suppression-reason-pattern = "^(SEC|PLAT)-[0-9]+ .+$"
require-suppression-expiration = true
max-suppression-days = 90
report-unused-suppressions = true

approved-registries = ["docker.io", "ghcr.io", "registry.example.com"]
approved-base-images = ["alpine:3.*", "registry.example.com/platform/*@sha256:*"]

[severity-overrides]
DF001 = "error"
DF020 = "error"
DF065 = "error"

[required-labels]
"org.opencontainers.image.source" = "url"
"org.opencontainers.image.version" = "semver"
"org.opencontainers.image.revision" = "hash"
"org.opencontainers.image.licenses" = "spdx"

[[overrides]]
paths = ["**/Dockerfile.dev", "**/Dockerfile.test"]
skip = ["DF012", "DF022"]
```

See [`examples/droast-enterprise.toml`](examples/droast-enterprise.toml) for a complete copy-paste starting point.

### Configuration keys

| Key | Type | Values |
|---|---|---|
| `skip` | array of strings | Rule IDs such as `DF012` |
| `extends` | string or array | Local configuration files to inherit |
| `preset` | string | Built-in preset name |
| `min-severity` | string | `info`, `warning`, `error` |
| `categories` | array | Run matching rule categories |
| `skip-categories` | array | Skip matching rule categories |
| `severity-overrides` | table | Change individual rule severities |
| `inline-suppressions` | boolean | Allow governed suppression comments |
| `require-suppression-reason` | boolean | Require a non-empty reason |
| `suppression-reason-pattern` | string | Validate reasons with a regular expression |
| `require-suppression-expiration` | boolean | Require `expires=YYYY-MM-DD` |
| `max-suppression-days` | integer | Limit exception lifetime |
| `report-unused-suppressions` | boolean | Report stale exceptions |
| `approved-registries` | array | Registry allowlist with glob support |
| `extend-approved-registries` | array | Add to the inherited registry allowlist |
| `approved-base-images` | array | Base-image allowlist with glob support |
| `extend-approved-base-images` | array | Add to the inherited image allowlist |
| `required-labels` | table | Required label names and formats |
| `strict-labels` | boolean | Reject labels outside the schema |
| `overrides` | array of tables | Apply settings to matching paths |
| `no-roast` | boolean | `true`, `false` |
| `no-fail` | boolean | `true`, `false` |
| `format` | string | `terminal`, `json`, `github`, `compact`, `sarif` |

Unknown keys are rejected. This catches misspelled configuration early.

Unknown rule IDs, categories, severities, presets, label formats, regular expressions, inheritance cycles, and glob patterns are also rejected. CI does not silently continue with a broken policy.

### Editor schema

TOML editors that support schema directives can validate keys and values while you type:

```toml
#:schema https://raw.githubusercontent.com/immanuwell/dockerfile-roast/main/schemas/droast.schema.json

preset = "production"
```

The schema is stored at [`schemas/droast.schema.json`](schemas/droast.schema.json). Runtime validation remains authoritative and also checks registered rule IDs, inheritance, and regular expressions.

### Discovery and precedence

droast searches from the current directory upward. It stops at the repository boundary or filesystem root.

Precedence for scalar value options is:

1. CLI option
2. `droast.toml`
3. built-in default

The `skip` list is different. CLI and configuration values are combined.

Boolean switches such as `--no-roast` and `--no-fail` enable the matching behavior. If either the CLI or configuration enables one, it stays enabled for that run.

```toml
# droast.toml
skip = ["DF012"]
```

```bash
# Both DF012 and DF022 are skipped.
droast --skip DF022 .
```

### Explicit configuration

Use a project-specific file:

```bash
droast --config .droast/team.toml .
```

### CLI-only controls

`--only` and `--check-dockerignore` are CLI-only. They are not TOML keys.

### Per-rule severity overrides

Turn a recommendation into a release blocker without changing the rule itself:

```toml
[severity-overrides]
DF001 = "error"
DF020 = "error"
DF033 = "warning"
DF065 = "error"
```

Overrides are applied before `min-severity`. For example, an info rule promoted to warning remains visible when `min-severity = "warning"`.

### Rule categories

Every rule has one or more categories:

- `correctness`
- `maintainability`
- `performance`
- `reliability`
- `reproducibility`
- `security`
- `supply-chain`

Inspect categories:

```bash
droast --list-rules
droast --list-rules --format json | jq '.[] | {id, categories}'
```

Run only security and supply-chain rules:

```toml
categories = ["security", "supply-chain"]
```

Or use the CLI:

```bash
droast --category security,supply-chain .
```

Skip a category while keeping the rest:

```toml
skip-categories = ["maintainability"]
```

`--only` is the most specific selector. When it is present, category selection does not hide the requested rule IDs. Explicit `skip` values still apply.

`DF071` syntax validation and `DF072` suppression-policy validation run with every selected category unless they are explicitly skipped. Other rules cannot be trusted when the source or its exceptions are invalid.

### Inline suppressions

Suppress one rule for the next Dockerfile instruction:

```dockerfile
# droast ignore=DF001 reason="PLAT-142 legacy vendor image" expires=2026-09-30
FROM vendor.example.com/runtime:latest
```

Suppress multiple rules:

```dockerfile
# droast ignore=DF001,DF065 reason="SEC-819 reviewed migration image" expires=2026-09-30
FROM migration.example.net/runtime:latest
```

Use a file-wide suppression before the first instruction:

```dockerfile
# droast global ignore=DF020 reason="PLAT-88 runtime injects numeric user" expires=2026-09-30
FROM gcr.io/distroless/static-debian12:nonroot
COPY app /app
ENTRYPOINT ["/app"]
```

The normal directive applies only to the next logical instruction. Blank lines and ordinary comments between the directive and instruction are safe. A directive inside a `RUN` heredoc is shell content and is not treated as a Dockerfile suppression.

`DF072` reports invalid, expired, disabled, misplaced, or stale directives. `DF072` itself cannot be suppressed inline.

Replace example expiration dates with a current, policy-compliant date when copying a directive.

### Suppression governance

Keep defaults lightweight:

```toml
inline-suppressions = true
require-suppression-reason = false
require-suppression-expiration = false
report-unused-suppressions = false
```

Use a governed enterprise policy:

```toml
inline-suppressions = true
require-suppression-reason = true
suppression-reason-pattern = "^(SEC|PLAT)-[0-9]+ .+$"
require-suppression-expiration = true
max-suppression-days = 90
report-unused-suppressions = true
```

Behavior:

- a missing reason rejects the suppression
- a reason that does not match the configured pattern rejects it
- an invalid or past date rejects it
- a date beyond `max-suppression-days` rejects it
- a rejected suppression never hides the original finding
- an unused suppression is reported when enabled
- expiration uses UTC and remains valid through the named date

Disable all inline exceptions in a centrally controlled repository:

```toml
inline-suppressions = false
```

### Approved registries

Configure `DF065` as an explicit registry allowlist:

```toml
approved-registries = [
  "docker.io",
  "ghcr.io",
  "*.gcr.io",
  "registry.example.com",
  "registry.example.com:5000",
]
```

Short image names such as `alpine:3.20` resolve to `docker.io`. Glob patterns are case-insensitive. When this setting is absent, droast keeps its built-in trusted-registry behavior.

Add a repository exception without replacing an inherited list:

```toml
extend-approved-registries = ["mirror.example.com"]
```

### Approved base images

Restrict full external `FROM` references with `DF073`:

```toml
approved-base-images = [
  "alpine:3.*",
  "debian:12.*",
  "ghcr.io/example/runtime@sha256:*",
  "registry.example.com/platform/*@sha256:*",
]
```

Patterns match the full image reference. Internal multi-stage aliases are exempt. `scratch` is exempt. An empty configured list rejects every external base image.

Add to an inherited image list explicitly:

```toml
extend-approved-base-images = ["registry.example.com/team/runtime@sha256:*"]
```

For release images, prefer digest patterns from a controlled registry:

```toml
approved-base-images = ["registry.example.com/platform/*@sha256:*"]
```

### Required image labels

`DF074` validates labels on the final image stage:

```toml
[required-labels]
"org.opencontainers.image.source" = "url"
"org.opencontainers.image.created" = "rfc3339"
"org.opencontainers.image.version" = "semver"
"org.opencontainers.image.revision" = "hash"
"org.opencontainers.image.licenses" = "spdx"
"com.example.owner" = "email"
"com.example.cost-center" = "regex:^CC-[0-9]{4}$"
```

Supported formats:

| Format | Accepted value |
|---|---|
| `text` | Any non-empty text, including build-time variables |
| `url` | A valid URL |
| `semver` | A semantic version, optionally prefixed with `v` |
| `hash` | 7 through 64 hexadecimal characters |
| `rfc3339` | An RFC 3339 timestamp |
| `spdx` | A valid SPDX expression |
| `email` | A basic email address |
| `regex:<pattern>` | A value matching the custom regular expression |

Dynamic values such as `${VERSION}` can only satisfy `text`, because their final value is unknown during linting.

Reject undeclared labels:

```toml
strict-labels = true

[required-labels]
"org.opencontainers.image.source" = "url"
"org.opencontainers.image.version" = "semver"
```

### Path-specific configuration

Use ordered overrides for monorepos:

```toml
preset = "production"

[[overrides]]
paths = ["services/**/Dockerfile", "services/**/*.Dockerfile"]
min-severity = "error"

[overrides.severity-overrides]
DF020 = "error"

[[overrides]]
paths = ["**/Dockerfile.dev", "**/Dockerfile.test"]
skip = ["DF012", "DF022"]

[[overrides]]
paths = ["docker/release.Dockerfile"]
preset = "strict"
approved-base-images = ["registry.example.com/platform/*@sha256:*"]
```

Patterns are resolved relative to the configuration that declares them. Every matching block is applied in file order. Later scalar values win. Additive lists such as `skip` are combined.

Output `format` remains scan-wide because one repository run emits one document. Set it at the top level or on the CLI. Other path settings, including severity, presets, policy, `no-roast`, and `no-fail`, apply per Dockerfile.

### Inherited organization configuration

Inherit one or more policy files:

```toml
extends = [
  ".droast/organization.toml",
  ".droast/language-team.toml",
]

# Repository-specific additions follow.
extend-approved-base-images = ["registry.example.com/platform/java@sha256:*"]
```

Relative paths start at the file containing `extends`. Absolute paths are supported. Inheritance cycles and missing files fail clearly.

Merge behavior:

- parents are loaded from left to right
- the repository file is applied last
- scalar values use the nearest explicit value
- `skip` and `skip-categories` are additive
- `approved-registries` and `approved-base-images` replace inherited lists
- `extend-approved-registries` and `extend-approved-base-images` add entries explicitly
- severity overrides use the nearest value for each rule
- parent required-label formats cannot be weakened by a child
- required reason, required expiration, unused checks, strict labels, and disabled inline suppressions cannot be weakened by a child
- the shortest configured `max-suppression-days` wins
- path overrides are appended and evaluated in inherited order

Remote URLs are not fetched automatically. This keeps linting deterministic, offline-capable, and free from hidden network policy changes.

For an organization policy stored elsewhere, download a pinned revision in CI, verify it, then inherit the local file:

```bash
mkdir -p .droast
curl -fsSL \
  https://raw.githubusercontent.com/example/platform/0123456789abcdef/droast.toml \
  -o .droast/organization.toml
echo 'EXPECTED_SHA256  .droast/organization.toml' | sha256sum --check
droast .
```

Repository `droast.toml`:

```toml
extends = ".droast/organization.toml"
```

See [`examples/droast-organization.toml`](examples/droast-organization.toml) and [`examples/droast-repository.toml`](examples/droast-repository.toml).

### Why these controls exist

These patterns are established in mature tooling:

- [Hadolint configuration]https://github.com/hadolint/hadolint/blob/master/README.md provides severity overrides, trusted registries, label schemas, and inline ignores.
- [Ruff configuration]https://docs.astral.sh/ruff/configuration/ uses explicit inheritance and per-file configuration for large repositories.
- [ESLint bulk suppressions]https://eslint.org/docs/latest/use/suppressions treats committed suppressions and stale-suppression reporting as migration controls.
- [GitHub organization security configuration]https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security demonstrates centrally managed policy across repositories.

This is evidence of established team workflows, not a claim about private configuration inside any named company. Exact internal policies are rarely public.

droast keeps all of this optional. With no `droast.toml`, no policy-specific rule activates and existing lint defaults remain unchanged.

## Copy-paste presets

Presets are built in. Select one in `droast.toml` or with `--preset`. Explicit settings can refine a preset.

### Minimal

Use this for an existing repository that needs a low-noise first step.

```toml
preset = "minimal"
```

```bash
droast --preset minimal .
```

This reports error-severity findings and uses technical messages.

### Security

Use this focused set for unsafe users, leaked secrets, unsafe downloads, permissions, shell pipelines, and malformed input.

```toml
preset = "security"
```

```bash
droast --preset security .
```

This selects `security` and `supply-chain` categories at warning severity.

### Performance

Use this for layer count, package caches, build context size, and cache invalidation.

```toml
preset = "performance"
```

```bash
droast --preset performance .
```

This selects the `performance` category and includes info findings.

### Production

Use this as a balanced default for a team repository.

```toml
preset = "production"
```

```bash
droast --preset production .
```

This runs all categories at warning severity with technical messages. Add only reviewed exceptions to `skip`.

### Strict

Use this for new projects, release images, or a cleanup target.

```toml
preset = "strict"
```

```bash
droast --preset strict --check-dockerignore true .
```

This runs every rule, requires reasons and expiration dates for suppressions, and reports unused suppressions.

### Makefile shortcuts

```makefile
.PHONY: lint-docker lint-docker-security lint-docker-performance lint-docker-strict

lint-docker:
	droast --preset production .

lint-docker-security:
	droast --preset security .

lint-docker-performance:
	droast --preset performance .

lint-docker-strict:
	droast --preset strict --check-dockerignore true .
```

## Control rules and severity

### Severity levels

| Level | Typical meaning |
|---|---|
| `error` | Unsafe or invalid behavior that should be fixed |
| `warning` | Strong production recommendation |
| `info` | Optimization, documentation, or maintainability advice |

`--min-severity warning` includes warnings and errors. `--min-severity error` includes errors only.

### Skip selected rules

```bash
droast --skip DF012,DF022 .
```

Use a committed config for team-wide exceptions:

```toml
skip = [
  "DF012", # Batch job has no health endpoint.
  "DF022", # Internal worker does not listen on a port.
]
```

### Run a focused rule set

```bash
droast --only DF013,DF014,DF021 Dockerfile
```

### Rule IDs are case-insensitive

Both forms work:

```bash
droast --skip DF012 .
droast --skip df012 .
```

### Inline suppression

Use a governed exception directly above the affected instruction:

```dockerfile
# droast ignore=DF001 reason="PLAT-142 migration" expires=2026-09-30
FROM alpine:latest
```

See [Inline suppressions](#inline-suppressions) for global directives and policy controls.

## Output formats

### Terminal

This is the default human-readable output:

```bash
droast --format terminal Dockerfile
```

Keep personality enabled for local use:

```bash
droast Dockerfile
```

Use technical text for logs and team CI:

```bash
droast --no-roast Dockerfile
```

### Compact

Compact output is useful for editors and Unix pipelines:

```bash
droast --format compact --no-roast .
```

The output uses one finding per line with file, line, severity, rule, and message.

### JSON

```bash
droast --format json --no-roast Dockerfile > droast.json
```

A single input produces one result object. Multiple inputs produce an array of result objects.

Inspect all findings:

```bash
jq '.findings' droast.json
```

Count findings by severity for one file:

```bash
jq '.findings | group_by(.severity) | map({severity: .[0].severity, count: length})' droast.json
```

For repository output:

```bash
droast --format json --no-roast . > droast.json
jq '[.[].findings[]] | group_by(.severity) | map({severity: .[0].severity, count: length})' droast.json
```

### GitHub annotations

```bash
droast --format github --no-roast .
```

This emits workflow commands that GitHub renders as file annotations. The Marketplace action selects this format automatically.

### SARIF

Create a SARIF 2.1.0 report:

```bash
droast --format sarif --no-roast --no-fail . > droast.sarif
```

`--no-fail` lets the report upload step run even when droast finds errors.

### Quiet advisory runs

Keep findings but never block the caller:

```bash
droast --no-fail --no-roast .
```

## CI integration

Pin both the action and container image version for repeatable CI.

### GitHub Actions

Repository-wide annotations:

```yaml
name: Dockerfile lint

on:
  pull_request:
  push:
    branches: [main]

jobs:
  droast:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: immanuwell/dockerfile-roast@1.4.3
        with:
          files: .
          min-severity: warning
          no-roast: true
          image-tag: 1.4.3
```

The action defaults to the root `Dockerfile`. Set `files: .` for recursive repository discovery, Compose, and Bake awareness.

Action inputs:

| Input | Default | Purpose |
|---|---|---|
| `files` | `Dockerfile` | Space-separated paths or glob patterns |
| `min-severity` | config or `info` | Minimum reported severity |
| `preset` | empty | Select a built-in preset |
| `category` | empty | Comma-separated categories to run |
| `skip-category` | empty | Comma-separated categories to skip |
| `skip` | empty | Comma-separated rule IDs to skip |
| `no-roast` | `false` | Use technical messages only |
| `no-fail` | `false` | Keep the workflow step non-blocking |
| `image-tag` | `latest` | Select the container version used by the action |

Preset example:

```yaml
- uses: immanuwell/dockerfile-roast@1.4.3
  with:
    files: .
    preset: security
    image-tag: 1.4.3
```

Non-blocking rollout:

```yaml
- uses: immanuwell/dockerfile-roast@1.4.3
  with:
    files: .
    min-severity: info
    no-roast: true
    no-fail: true
    image-tag: 1.4.3
```

Skip reviewed exceptions:

```yaml
- uses: immanuwell/dockerfile-roast@1.4.3
  with:
    files: .
    skip: DF012,DF022
    no-roast: true
    image-tag: 1.4.3
```

### GitHub code scanning with SARIF

```yaml
name: Dockerfile code scanning

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read
  security-events: write

jobs:
  droast-sarif:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Generate SARIF
        run: |
          docker run --rm \
            -v "$GITHUB_WORKSPACE:/workspace" \
            -w /workspace \
            ghcr.io/immanuwell/droast:1.4.3 \
            --format sarif --no-roast --no-fail . > droast.sarif
      - uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: droast.sarif
```

### GitLab CI

GitLab can run droast directly as the job image. Clear the image entrypoint so
GitLab can execute the job script.

#### GitLab - lint every supported Dockerfile

```yaml
droast:
  stage: test
  image:
    name: ghcr.io/immanuwell/droast:1.4.3
    entrypoint: [""]
  script:
    - droast --no-roast --min-severity warning .
  rules:
    - changes:
        - "**/Dockerfile"
        - "**/Dockerfile.*"
        - "**/*.Dockerfile"
        - "**/Containerfile*"
        - "**/compose*.yml"
        - "**/compose*.yaml"
        - "**/docker-bake.*"
```

The `changes` rule avoids starting this job when a commit cannot affect a
Docker build. Remove `rules` if Compose or Bake files use non-standard names.

#### GitLab - strict merge requests and the default branch

```yaml
droast-strict:
  stage: test
  image:
    name: ghcr.io/immanuwell/droast:1.4.3
    entrypoint: [""]
  script:
    - droast --preset strict --no-roast .
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
```

This blocks merge-request and default-branch pipelines when the strict preset
finds a failing issue.

#### GitLab - keep a non-blocking JSON report

```yaml
droast-report:
  stage: test
  image:
    name: ghcr.io/immanuwell/droast:1.4.3
    entrypoint: [""]
  script:
    - mkdir -p reports
    - droast --format json --no-roast --no-fail . > reports/droast.json
  artifacts:
    when: always
    name: "droast-$CI_COMMIT_SHORT_SHA"
    paths:
      - reports/droast.json
    expire_in: 1 week
```

`--no-fail` keeps the rollout advisory. Remove it when the team is ready to
enforce the configured severity threshold.

See the [GitLab CI/CD YAML reference](https://docs.gitlab.com/ci/yaml/) for
runner-specific options.

### Bitbucket Pipelines

Bitbucket Pipelines can use the public droast image as a build environment.

#### Bitbucket - lint every branch

`bitbucket-pipelines.yml`:

```yaml
image: ghcr.io/immanuwell/droast:1.4.3

pipelines:
  default:
    - step:
        name: Lint Dockerfiles
        script:
          - droast --no-roast --min-severity warning .
```

#### Bitbucket - production preset on pull requests

```yaml
image: ghcr.io/immanuwell/droast:1.4.3

pipelines:
  pull-requests:
    '**':
      - step:
          name: Lint Dockerfiles
          script:
            - droast --preset production --no-roast .
```

Bitbucket pull-request pipelines run in addition to matching `default` or
branch pipelines. Use only the trigger sections you need to avoid duplicate
runs.

#### Bitbucket - keep a non-blocking JSON report

```yaml
image: ghcr.io/immanuwell/droast:1.4.3

pipelines:
  custom:
    droast-report:
      - step:
          name: Create droast report
          script:
            - mkdir -p reports
            - droast --format json --no-roast --no-fail . > reports/droast.json
          artifacts:
            - reports/droast.json
```

The `custom` pipeline is available for manual and scheduled runs.

#### Bitbucket - keep an existing build image

Use the Docker service when the step needs a different build image:

```yaml
image: atlassian/default-image:5

pipelines:
  default:
    - step:
        name: Lint Dockerfiles
        services:
          - docker
        script:
          - >-
            docker run --rm
            -v "$BITBUCKET_CLONE_DIR:/workspace:ro"
            -w /workspace
            ghcr.io/immanuwell/droast:1.4.3
            --no-roast --min-severity warning .
```

The clone directory is within Bitbucket's permitted bind-mount area. The
read-only mount is sufficient for linting.

See the [Bitbucket Pipelines configuration reference](https://support.atlassian.com/bitbucket-cloud/docs/bitbucket-pipelines-configuration-reference/)
for build images, triggers, services, and artifacts.

### CircleCI

```yaml
version: 2.1

jobs:
  droast:
    machine:
      image: ubuntu-2404:current
    steps:
      - checkout
      - run:
          name: Lint Dockerfiles
          command: |
            docker run --rm \
              -v "$PWD:/workspace" \
              -w /workspace \
              ghcr.io/immanuwell/droast:1.4.3 \
              --no-roast --min-severity warning .

workflows:
  lint:
    jobs:
      - droast
```

### Jenkins

These examples use Declarative Pipeline syntax.

#### Jenkins - use Docker from an existing agent

```groovy
pipeline {
  agent any
  stages {
    stage('Lint Dockerfiles') {
      steps {
        sh '''
          docker run --rm \
            -v "$WORKSPACE:/workspace" \
            -w /workspace \
            ghcr.io/immanuwell/droast:1.4.3 \
            --no-roast --min-severity warning .
        '''
      }
    }
  }
}
```

The selected Jenkins agent must have Docker installed and permission to use
the Docker daemon.

#### Jenkins - use droast as the stage agent

This variant requires the Jenkins Docker Pipeline plugin:

```groovy
pipeline {
  agent none
  stages {
    stage('Lint Dockerfiles') {
      agent {
        docker {
          image 'ghcr.io/immanuwell/droast:1.4.3'
          args '--entrypoint='
          reuseNode true
        }
      }
      steps {
        sh 'droast --preset production --no-roast .'
      }
    }
  }
}
```

Clearing the image entrypoint lets Jenkins start its normal agent command.
`reuseNode true` mounts the current workspace into the container.

#### Jenkins - keep a non-blocking JSON report

```groovy
pipeline {
  agent any
  stages {
    stage('Dockerfile report') {
      steps {
        sh '''
          mkdir -p reports
          docker run --rm \
            -v "$WORKSPACE:/workspace:ro" \
            -w /workspace \
            ghcr.io/immanuwell/droast:1.4.3 \
            --format json --no-roast --no-fail . > reports/droast.json
        '''
      }
    }
  }
  post {
    always {
      archiveArtifacts artifacts: 'reports/droast.json', fingerprint: true
    }
  }
}
```

`archiveArtifacts` keeps the report with the Jenkins build. Remove
`--no-fail` to make findings block the pipeline.

See the Jenkins references for [Pipeline syntax](https://www.jenkins.io/doc/book/pipeline/syntax/)
and [Docker agents](https://www.jenkins.io/doc/book/pipeline/docker/).

### Azure Pipelines

Microsoft-hosted Ubuntu agents include Docker. Self-hosted agents need a
running Docker daemon.

#### Azure - lint pushes and pull requests

```yaml
trigger:
  branches:
    include:
      - main

pr:
  branches:
    include:
      - main

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
  - bash: |
      docker run --rm \
        -v "$(Build.SourcesDirectory):/workspace:ro" \
        -w /workspace \
        ghcr.io/immanuwell/droast:1.4.3 \
        --no-roast --min-severity warning .
    displayName: Lint Dockerfiles
```

The YAML `pr` trigger works with GitHub and Bitbucket Cloud repositories.
Azure Repos Git uses a build-validation branch policy for pull requests.

#### Azure - strict pull-request policy

```yaml
trigger: none

pr:
  branches:
    include:
      - main

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
  - bash: |
      docker run --rm \
        -v "$(Build.SourcesDirectory):/workspace:ro" \
        -w /workspace \
        ghcr.io/immanuwell/droast:1.4.3 \
        --preset strict --no-roast .
    displayName: Enforce strict Dockerfile policy
```

Add this pipeline to the target branch's build validation policy when Azure
Repos should require it before merging. For GitHub and Bitbucket Cloud, the
YAML `pr` trigger starts it directly.

#### Azure - keep a non-blocking JSON report

```yaml
trigger:
  - main

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
  - bash: |
      mkdir -p "$(Build.ArtifactStagingDirectory)/droast"
      docker run --rm \
        -v "$(Build.SourcesDirectory):/workspace:ro" \
        -w /workspace \
        ghcr.io/immanuwell/droast:1.4.3 \
        --format json --no-roast --no-fail . \
        > "$(Build.ArtifactStagingDirectory)/droast/droast.json"
    displayName: Create droast report
  - publish: $(Build.ArtifactStagingDirectory)/droast
    artifact: droast
    condition: always()
    displayName: Publish droast report
```

The `publish` shortcut creates a pipeline artifact in Azure DevOps Services.
Azure DevOps Server users should use `PublishBuildArtifacts@1` instead.

See the Azure references for [Docker on hosted agents](https://learn.microsoft.com/azure/devops/pipelines/ecosystems/containers/build-image)
and [pipeline artifacts](https://learn.microsoft.com/azure/devops/pipelines/artifacts/pipeline-artifacts).

## Local development workflows

### pre-commit

Install [pre-commit](https://pre-commit.com/) and add:

```yaml
repos:
  - repo: local
    hooks:
      - id: droast
        name: droast
        entry: droast --no-roast --min-severity warning .
        language: system
        pass_filenames: false
        always_run: true
```

Run it:

```bash
pre-commit run droast --all-files
```

### Git pre-push hook

`.git/hooks/pre-push`:

```bash
#!/usr/bin/env bash
set -euo pipefail
droast --preset production .
```

Enable it:

```bash
chmod +x .git/hooks/pre-push
```

For a team, manage hooks through a committed hook manager instead of copying `.git/hooks` manually.

### Changed Dockerfiles only

```bash
git diff --name-only --diff-filter=ACMR origin/main...HEAD \
  | grep -E '(^|/)(Dockerfile($|\.)|.*\.Dockerfile$|Containerfile($|\.))' \
  | xargs -r droast --no-roast
```

Use `droast .` in CI when Compose, Bake, or build-context resolution matters.

## Docker and container usage

### Lint a repository

```bash
docker run --rm \
  -v "$PWD:/workspace" \
  -w /workspace \
  ghcr.io/immanuwell/droast:1.4.3 \
  --no-roast .
```

### Lint one file

```bash
docker run --rm \
  -v "$PWD:/workspace" \
  -w /workspace \
  ghcr.io/immanuwell/droast:1.4.3 \
  Dockerfile
```

### Write JSON to the host

```bash
docker run --rm \
  -v "$PWD:/workspace" \
  -w /workspace \
  ghcr.io/immanuwell/droast:1.4.3 \
  --format json --no-roast --no-fail . > droast.json
```

### Read-only mount

Linting does not need to change the repository:

```bash
docker run --rm \
  -v "$PWD:/workspace:ro" \
  -w /workspace \
  ghcr.io/immanuwell/droast:1.4.3 \
  --no-roast .
```

## Wasmer and WASI

The Wasmer package provides the same command-line interface through WASI. Stdin linting needs no filesystem permission:

```bash
wasmer run immanuwell/droast -- \
  --only DF001,DF002 --check-dockerignore=false - < Dockerfile
```

For repository discovery, Compose, Bake, `.dockerignore`, and project configuration, mount the repository and use guest paths:

```bash
wasmer run --volume "$PWD:/workspace" immanuwell/droast -- \
  --config /workspace/droast.toml /workspace
```

Build and validate the package locally:

```bash
./scripts/build-wasmer-package.sh
wasmer run target/wasmer/droast.webc -- --version
```

## VS Code

The extension shows findings as editor diagnostics while Dockerfiles are edited.

Install it:

```bash
code --install-extension ImmanuelTikhonov.droast
```

### Settings

`.vscode/settings.json`:

```json
{
  "droast.enable": true,
  "droast.executablePath": "",
  "droast.minSeverity": "warning",
  "droast.skipRules": ["DF012", "DF022"],
  "droast.noRoast": true
}
```

| Setting | Purpose |
|---|---|
| `droast.enable` | Enable or disable linting |
| `droast.executablePath` | Use a specific executable path |
| `droast.minSeverity` | Select `info`, `warning`, or `error` |
| `droast.skipRules` | Suppress rule IDs |
| `droast.noRoast` | Show technical text only |

Leave `droast.executablePath` empty to use the bundled executable or a `droast` executable on `PATH`.

## Web version

Open [the droast web linter](https://ewry.net/droast-dockerfile-linter/).

Paste a Dockerfile to get immediate findings without installing a binary. The linter runs in the browser through WebAssembly, so the Dockerfile does not need to be sent to a linting service.

Use the web version for quick experiments. Use the CLI for repository discovery, effective build contexts, `.dockerignore`, configuration, output formats, and CI.

## Rust library

The crate exposes parser, rules, linter, repository, configuration, and output modules.

Add it:

```toml
[dependencies]
dockerfile-roast = "1.4.3"
```

### Lint text

```rust
use dockerfile_roast::linter::{lint_content, LintOptions};
use dockerfile_roast::rules::Severity;

fn main() {
    let source = "FROM alpine:latest\nUSER root\n";
    let options = LintOptions {
        skip_rules: vec![],
        only_rules: vec![],
        min_severity: Severity::Info,
        check_dockerignore: false,
        ..LintOptions::default()
    };

    let result = lint_content(source, "Dockerfile", &options);
    for finding in result.findings {
        println!(
            "{}:{} {} {}",
            result.file, finding.line, finding.severity, finding.rule
        );
    }
}
```

### Lint a file

```rust
use std::path::Path;
use dockerfile_roast::linter::{lint_file, LintOptions};
use dockerfile_roast::rules::Severity;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let options = LintOptions {
        skip_rules: vec!["DF012".into()],
        only_rules: vec![],
        min_severity: Severity::Warning,
        check_dockerignore: true,
        ..LintOptions::default()
    };

    let result = lint_file(Path::new("Dockerfile"), &options)?;
    println!("{} findings", result.findings.len());
    Ok(())
}
```

### Select rules in code

```rust
let options = LintOptions {
    skip_rules: vec![],
    only_rules: vec!["DF013".into(), "DF014".into(), "DF021".into()],
    min_severity: Severity::Warning,
    check_dockerignore: false,
    ..LintOptions::default()
};
```

## Parser API

Use `parse_document` when an integration needs structured Dockerfile data.

```rust
use dockerfile_roast::parser::{parse_document, InstructionForm};

fn main() {
    let source = r#"# syntax=docker/dockerfile:1.7
FROM alpine:3.20
RUN --mount=type=cache,target=/cache echo "$HOME"
"#;

    let document = parse_document(source);

    println!("escape character: {}", document.escape);
    for directive in &document.directives {
        println!("directive: {}={}", directive.name, directive.value);
    }

    for instruction in &document.instructions {
        println!("{} at line {}", instruction.instruction, instruction.line);
        println!("source: {}", instruction.span.text(source));
        println!("flags: {}", instruction.flags.len());

        if let InstructionForm::Json(values) = &instruction.form {
            println!("JSON arguments: {values:?}");
        }
    }

    for diagnostic in &document.diagnostics {
        println!("{}: {}", diagnostic.code, diagnostic.message);
    }
}
```

Important structured fields include:

- parser directives and the effective escape character
- exact instruction, keyword, and argument spans
- normalized command text after BuildKit flags
- structured flags and their values
- words, quote styles, and variable references
- shell, JSON, and invalid JSON forms
- heredoc delimiters, bodies, expansion mode, and spans
- recoverable parser diagnostics

`parse` remains available when only the instruction list is needed:

```rust
use dockerfile_roast::parser::parse;

let instructions = parse("FROM alpine:3.20\n");
```

## Rule catalog

Run `droast --list-rules` for the authoritative list in the installed version. This catalog describes all 74 current rules.

### Base images, stages, and reproducibility

| Rule | Severity | Check |
|---|---|---|
| DF001 | warning | Use a specific base image tag instead of `latest` |
| DF005 | info | Pin package versions for repeatable builds |
| DF011 | warning | Use multi-stage builds when they reduce the final image |
| DF023 | warning | Give multiple `FROM` stages aliases |
| DF024 | warning | Avoid `:latest` on aliased stages |
| DF042 | error | Keep stage aliases unique |
| DF061 | warning | Avoid fixed `--platform` in `FROM` unless required |
| DF065 | warning | Review images from unrecognized registries |
| DF069 | warning | Avoid package upgrades that make builds non-repeatable |
| DF073 | error | Require base images approved by configured policy |

### Users, secrets, and command safety

| Rule | Severity | Check |
|---|---|---|
| DF002 | error | Do not leave the final image running as root |
| DF010 | warning | Do not use `sudo` inside a container |
| DF013 | error | Do not store secrets in `ENV` |
| DF014 | error | Do not hardcode passwords or tokens in `ARG` or `ENV` |
| DF020 | warning | Set an explicit non-root `USER` |
| DF021 | error | Do not pipe remote downloads directly to a shell |
| DF034 | error | Do not use `chmod 777` |
| DF057 | warning | Set `pipefail` for shell pipelines |
| DF066 | warning | Set an appropriate `SHELL` before Bash-specific syntax |

### Layers, files, and build context

| Rule | Severity | Check |
|---|---|---|
| DF003 | warning | Combine related `RUN` commands to reduce layers |
| DF006 | warning | Prefer `COPY` over `ADD` for local files |
| DF007 | warning | Avoid broad `COPY . .` operations |
| DF008 | info | Use `WORKDIR` instead of inline `cd` |
| DF009 | warning | Use absolute `WORKDIR` paths |
| DF026 | warning | Avoid recursive copies from filesystem root |
| DF033 | info | Use an effective `.dockerignore` for each build context |
| DF048 | error | End multi-source `COPY` destinations with `/` |
| DF049 | warning | Copy only from an earlier, defined stage |
| DF050 | error | Do not copy from the current stage |
| DF063 | warning | Set `WORKDIR` before a relative `COPY` destination |
| DF067 | info | Consider `ADD` when local tar auto-extraction is intended |
| DF070 | warning | Avoid a broad copy before dependency installation |

### Package managers and caches

| Rule | Severity | Check |
|---|---|---|
| DF004 | warning | Clean OS package caches in the same layer |
| DF015 | error | Pass `-y` to `apt-get` in non-interactive builds |
| DF016 | info | Use `--no-install-recommends` with `apt-get` |
| DF027 | error | Pass `-y` to `yum` |
| DF028 | warning | Combine `apt-get update` with installation |
| DF029 | warning | Use `apk add --no-cache` |
| DF030 | info | Use pip `--no-cache-dir` |
| DF031 | info | Prefer `npm ci` and production-aware installation |
| DF043 | warning | Make `zypper install` non-interactive |
| DF044 | warning | Avoid `zypper dist-upgrade` in an image build |
| DF045 | info | Clean zypper metadata after installation |
| DF046 | warning | Run `dnf clean all` after installation |
| DF047 | warning | Run `yum clean all` after installation |
| DF051 | warning | Pin versions installed by pip |
| DF052 | warning | Pin versions installed by apk |
| DF053 | warning | Pin versions installed by gem |
| DF054 | warning | Pin `go install` targets with `@version` |
| DF055 | info | Clean the Yarn cache after installation |
| DF059 | warning | Use `apt-get` or `apt-cache` instead of `apt` in scripts |

### Downloads and network tools

| Rule | Severity | Check |
|---|---|---|
| DF035 | info | Make curl fail on HTTP and transfer errors |
| DF056 | info | Limit wget progress output in build logs |
| DF058 | warning | Use either wget or curl consistently |

### Runtime behavior and metadata

| Rule | Severity | Check |
|---|---|---|
| DF012 | info | Add a health check to long-running services |
| DF017 | warning | Use `ENTRYPOINT` with `CMD` for flexible arguments |
| DF018 | warning | Prefer JSON form for `ENTRYPOINT` |
| DF019 | warning | Replace deprecated `MAINTAINER` with `LABEL` |
| DF022 | info | Document listening ports with `EXPOSE` |
| DF025 | warning | Prefer JSON form for `CMD` and `ENTRYPOINT` |
| DF032 | info | Set recommended Python runtime environment variables |
| DF036 | warning | Give runnable images a `CMD` or `ENTRYPOINT` |
| DF038 | warning | Keep only one effective `CMD` |
| DF039 | error | Keep only one effective `ENTRYPOINT` |
| DF040 | error | Keep `EXPOSE` ports in the range 0 through 65535 |
| DF041 | error | Keep only one effective `HEALTHCHECK` |
| DF060 | info | Remove pointless interactive commands |
| DF062 | error | Do not self-reference an `ENV` variable in one statement |
| DF064 | warning | Use `useradd -l` to avoid oversized user metadata layers |
| DF068 | error | Do not use forbidden instructions as `ONBUILD` triggers |
| DF074 | error | Require final-stage labels to match configured policy |

### Syntax

| Rule | Severity | Check |
|---|---|---|
| DF037 | error | Begin with `FROM`, global `ARG`, or a comment |
| DF071 | error | Keep Dockerfile syntax valid |
| DF072 | error | Require valid and governed suppression directives |

## Adoption recipes

### Existing repository with many findings

Start without blocking:

```toml
min-severity = "error"
no-roast = true
no-fail = true
format = "terminal"
```

Then:

1. Fix all error findings.
2. Change `no-fail` to `false`.
3. Raise `min-severity` to `warning`.
4. Review remaining rules one category at a time.
5. Record only justified exceptions in `skip`.
6. Move toward the strict preset.

### New service

Use strict checks from the first commit:

```bash
droast --preset strict --check-dockerignore true .
```

Run the same command locally, in pre-commit, and in CI.

### Security gate plus full advisory scan

Use two CI jobs:

```bash
# Blocking security gate
droast --no-roast \
  --preset security .

# Full advisory report
droast --no-roast --no-fail --min-severity info .
```

### Release image review

Lint the actual release Dockerfile and its context through the repository entry point:

```bash
droast --preset strict .
docker build -f docker/release.Dockerfile .
```

This lets Compose, Bake, and `.dockerignore` context logic stay consistent with repository use.

### Machine-readable quality report

```bash
droast --format json --no-roast --no-fail . > droast.json
droast --format sarif --no-roast --no-fail . > droast.sarif
```

Use JSON for custom dashboards. Use SARIF for code scanning systems.

## Troubleshooting

### No Dockerfiles were found

Check the current directory and file names:

```bash
pwd
find . -type f \( \
  -name 'Dockerfile' -o \
  -name 'Dockerfile.*' -o \
  -name '*.Dockerfile' -o \
  -name 'Containerfile' -o \
  -name 'Containerfile.*' \
\)
```

Then pass the intended repository root:

```bash
droast /path/to/repository
```

### GitHub Action checks only one file

The action defaults to `Dockerfile`. Enable repository discovery:

```yaml
with:
  files: .
```

### DF033 reports the wrong context

Run droast from the repository root so Compose and Bake files can define the build context:

```bash
droast .
```

Check whether a Dockerfile-specific ignore file overrides the root file:

```bash
find . -name '*.dockerignore' -o -name '.dockerignore'
```

### A Compose or Bake Dockerfile is missing

Confirm its context and Dockerfile path resolve locally. Remote Git and image contexts are not downloaded. Also check Compose `.env` values and Bake variable defaults.

### JSON parsing fails after adding more files

Single-file JSON is an object. Multi-file JSON is an array.

Single file:

```bash
jq '.findings' droast.json
```

Multiple files:

```bash
jq '.[].findings' droast.json
```

### The process exits successfully with warnings

Exit code `1` is reserved for error-severity findings and execution failures. Warnings are still printed. Use focused `--only` checks or inspect structured output when selected warnings must gate a workflow.

### The process exits with findings but CI must continue

```bash
droast --no-fail .
```

For SARIF, keep `--no-fail` on the generation step so the upload step runs.

### A config option has no effect

Check the active file and precedence:

```bash
droast --config ./droast.toml --help
```

CLI values override scalar configuration values. `skip` values are combined. `--only` and `--check-dockerignore` are CLI-only.

### VS Code cannot find droast

Set an absolute executable path:

```json
{
  "droast.executablePath": "/usr/local/bin/droast"
}
```

On Windows, point it to `droast.exe`.

### Shell expands a file pattern too early

Quote patterns when the shell should pass them unchanged:

```bash
droast 'services/*/Dockerfile'
```

For full recursive discovery, prefer:

```bash
droast .
```

## FAQ

### Does droast modify Dockerfiles?

No. Linting is read-only.

### Is configuration required?

No. `droast .` works without configuration.

### Which preset should a team start with?

Use `minimal` for a mature repository with existing debt. Use `production` for a normal team baseline. Use `strict` for new or release-critical images.

### Are presets built in?

Yes. Use `preset = "production"` in `droast.toml` or `droast --preset production .`. Explicit configuration can refine the selected preset.

### Can droast scan a monorepo?

Yes. Run `droast .` at the monorepo root. It recursively discovers conventional names plus Compose and Bake references.

### Does it understand BuildKit Dockerfiles?

Yes. The parser understands syntax directives, generic instruction flags, heredocs, and modern `RUN --mount` forms.

### Does it support Windows Dockerfiles?

Yes. It handles escape directives, Windows paths, CRLF files, JSON forms, and PowerShell-oriented Dockerfiles.

### Can it be used without the roast messages?

Yes:

```bash
droast --no-roast .
```

### Can it produce code scanning output?

Yes. Use `--format sarif` for SARIF 2.1.0, or `--format github` for GitHub workflow annotations.

### Where should shared exceptions live?

Put reviewed exceptions in the repository's `droast.toml`. Add a short comment explaining each design choice.

### How do I see the authoritative rule list?

Run the installed executable:

```bash
droast --list-rules
```

### Where can I report a problem?

Open an issue in the [dockerfile-roast repository](https://github.com/immanuwell/dockerfile-roast/issues).