Skip to content

Commit c10c388

Browse files
authored
Merge pull request asbjornenge#17 from andyneff/multistage
Multistage support for FROM, AS, COPY, and ARG
2 parents 79e5671 + 92ad882 commit c10c388

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

Syntaxes/Dockerfile.sublime-syntax

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,50 @@ first_line_match: \s*(FROM|ARG)\s
88
scope: source.dockerfile
99

1010
variables:
11-
build_directive: (?:(ONBUILD)\s+)?(ADD|ARG|COPY|ENV|EXPOSE|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)
12-
runtime_directive: (?:(ONBUILD)\s+)?(CMD|ENTRYPOINT)
11+
onbuild_directive: (?:(ONBUILD)\s+)?
12+
onbuild_commands_directive: "{{onbuild_directive}}(?:ADD|ARG|ENV|EXPOSE|HEALTHCHECK|LABEL|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)"
13+
nononbuild_commands_directive: MAINTAINER
14+
runtime_directive: "{{onbuild_directive}}(?:CMD|ENTRYPOINT)"
15+
from_directive: (FROM)\s+[^\s:@]+(?:[:@](\S+))?(?:\s+(AS)\s+(\S+))?
16+
copy_directive: ({{onbuild_directive}}COPY)(?:\s+--from=(\S+))?
1317

1418
contexts:
1519
main:
1620
- include: comments
17-
- match: ^FROM\s
21+
- match: ^ARG\s
1822
scope: keyword.control.dockerfile
23+
- include: from
24+
25+
from:
26+
- match: ^{{from_directive}}
27+
captures:
28+
1: keyword.control.dockerfile
29+
2: entity.name.enum.tag-digest
30+
3: keyword.control.dockerfile
31+
4: variable.stage-name
1932
push: body
2033

2134
body:
2235
- include: comments
2336
- include: directives
2437
- include: invalid
38+
- include: from
2539

2640
directives:
27-
- match: ^\s*{{build_directive}}\s
41+
- match: ^\s*{{onbuild_commands_directive}}\s
2842
captures:
2943
0: keyword.control.dockerfile
3044
1: keyword.other.special-method.dockerfile
3145
push: args
46+
- match: ^\s*{{nononbuild_commands_directive}}\s
47+
scope: keyword.control.dockerfile
48+
push: args
49+
- match: ^\s*{{copy_directive}}\s
50+
captures:
51+
1: keyword.control.dockerfile
52+
2: keyword.other.special-method.dockerfile
53+
3: variable.stage-name
54+
push: args
3255
- match: ^\s*{{runtime_directive}}\s
3356
captures:
3457
0: keyword.operator.dockerfile

0 commit comments

Comments
 (0)