|
| 1 | +// CodeMirror, copyright (c) by Marijn Haverbeke and others |
| 2 | +// Distributed under an MIT license: http://codemirror.net/LICENSE |
| 3 | + |
| 4 | +(function() { |
| 5 | + var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-dockerfile"); |
| 6 | + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } |
| 7 | + |
| 8 | + MT("simple_nodejs_dockerfile", |
| 9 | + "[keyword FROM] node:carbon", |
| 10 | + "[comment # Create app directory]", |
| 11 | + "[keyword WORKDIR] /usr/src/app", |
| 12 | + "[comment # Install app dependencies]", |
| 13 | + "[comment # A wildcard is used to ensure both package.json AND package-lock.json are copied]", |
| 14 | + "[comment # where available (npm@5+)]", |
| 15 | + "[keyword COPY] package*.json ./", |
| 16 | + "[keyword RUN] npm install", |
| 17 | + "[keyword COPY] . .", |
| 18 | + "[keyword EXPOSE] 8080 3000", |
| 19 | + "[keyword ENV] NODE_ENV development", |
| 20 | + "[keyword CMD] [[\"npm\", \"start\"]]"); |
| 21 | + |
| 22 | + // Ideally the last space should not be highlighted. |
| 23 | + MT("instruction_without_args_1", |
| 24 | + "[keyword CMD ]"); |
| 25 | + |
| 26 | + MT("instruction_without_args_2", |
| 27 | + "[comment # An instruction without args...]", |
| 28 | + "[keyword ARG] [error #...is an error]"); |
| 29 | + |
| 30 | + MT("multiline", |
| 31 | + "[keyword RUN] apt-get update && apt-get install -y \\", |
| 32 | + " mercurial \\", |
| 33 | + " subversion \\", |
| 34 | + " && apt-get clean \\", |
| 35 | + " && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*"); |
| 36 | + |
| 37 | + MT("from_comment", |
| 38 | + " [keyword FROM] debian:stretch [comment # I tend to use stable as that is more stable]", |
| 39 | + " [keyword FROM] debian:stretch [keyword AS] stable [comment # I am even more stable]", |
| 40 | + " [keyword FROM] [error # this is an error]"); |
| 41 | + |
| 42 | + MT("from_as", |
| 43 | + "[keyword FROM] golang:1.9.2-alpine3.6 [keyword AS] build", |
| 44 | + "[keyword COPY] --from=build /bin/project /bin/project", |
| 45 | + "[keyword ENTRYPOINT] [[\"/bin/project\"]]", |
| 46 | + "[keyword CMD] [[\"--help\"]]"); |
| 47 | + |
| 48 | + MT("arg", |
| 49 | + "[keyword ARG] VERSION=latest", |
| 50 | + "[keyword FROM] busybox:$VERSION", |
| 51 | + "[keyword ARG] VERSION", |
| 52 | + "[keyword RUN] echo $VERSION > image_version"); |
| 53 | + |
| 54 | + MT("label", |
| 55 | + "[keyword LABEL] com.example.label-with-value=\"foo\"", |
| 56 | + "[keyword LABEL] description=\"This text illustrates \"", |
| 57 | + " that label-values can span multiple lines.\""); |
| 58 | + |
| 59 | + MT("maintainer", |
| 60 | + "[keyword MAINTAINER] Foo Bar \"foo@bar.com\"", |
| 61 | + "[keyword MAINTAINER] Bar Baz <bar@baz.com>"); |
| 62 | + |
| 63 | + MT("verify_keyword", |
| 64 | + "[keyword RUN] add-apt-repository ppa:chris-lea/node.js"); |
| 65 | + |
| 66 | + MT("scripts", |
| 67 | + "[comment # Set an entrypoint, to automatically install node modules]", |
| 68 | + "[keyword ENTRYPOINT] [[\"/bin/bash\", \"-c\", \"if [[ ! -d node_modules ]]; then npm install; fi; exec \\\"${@:0}\\\";\"]]", |
| 69 | + "[keyword CMD] npm start", |
| 70 | + "[keyword RUN] npm run build && npm run test"); |
| 71 | +})(); |
0 commit comments