1 | import { SoftwareEnvironment } from '@stencila/schema';
|
2 | import Doer from './Doer';
|
3 | /**
|
4 | * Parser for Dockerfiles
|
5 | *
|
6 | * This class implements Dockerfile parsing. It extracts meta-data defined in a Dockerfile using
|
7 | * the [`LABEL`](https://docs.docker.com/engine/reference/builder/#label) or
|
8 | * deprecated [`MAINTAINER`](https://docs.docker.com/engine/reference/builder/#maintainer-deprecated) instructions.
|
9 | * Unlike the other parsers in Dockter it does not attempt to parse out dependencies.
|
10 | *
|
11 | * Here "label" refers to a key in a LABEL instruction that is un-prefixed
|
12 | * or has either the [`org.opencontainers.image`](https://github.com/opencontainers/image-spec/blob/master/annotations.md) prefix,
|
13 | * or the deprecated [`org.label-schema`](https://github.com/label-schema/label-schema.org) prefix.
|
14 | * In other words, the following are all equivalent:
|
15 | *
|
16 | * ```Dockerfile
|
17 | * LABEL version = 1.2.0
|
18 | * LABEL org.opencontainers.image.version = 1.2.0
|
19 | * LABEL org.label-schema.version = 1.2.0
|
20 | * ```
|
21 | *
|
22 | * The following [schema crosswalk](https://en.wikipedia.org/wiki/Schema_crosswalk) defines how labels in
|
23 | * Dockerfiles are translated into JSON-LD properties
|
24 | *
|
25 | * | Label | Property (`context:type.property`)
|
26 | * | --- | ----
|
27 | * | `authors` | `schema:CreativeWork.author`
|
28 | * | `build` |
|
29 | * | `created` | `schema:SoftwareSourceCode.dateCreated`
|
30 | * | `description` | `schema:Thing.description`
|
31 | * | `documentation` | `schema:softwareHelp`
|
32 | * | `licenses` | `schema:CreativeWork.license`
|
33 | * | `maintainer` | `codemeta:SoftwareSourceCode.maintainer`
|
34 | * | `ref-name` |
|
35 | * | `revision` |
|
36 | * | `schema-version` | `schema:schemaVersion`
|
37 | * | `source` | `schema:SoftwareSourceCode.codeRepository`
|
38 | * | `title` | `schema:Thing.name`
|
39 | * | `url` | `schema:Thing.url`
|
40 | * | `vendor` | `schema:Organization.legalName`
|
41 | * | `version` | `schema:SoftwareApplication.softwareVersion`
|
42 | *
|
43 | */
|
44 | export default class DockerParser extends Doer {
|
45 | /**
|
46 | * Parse a folder by detecting any Dockerfile
|
47 | * and return a `SoftwareEnvironment` instance
|
48 | */
|
49 | parse(content?: string): Promise<SoftwareEnvironment | null>;
|
50 | }
|