forked from element-hq/ems-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (40 loc) · 1.93 KB
/
Dockerfile
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
FROM node:12-alpine as builder
ARG MARKDOWN_CLI_VERSION="0.26.0"
# install packages
RUN set -x \
# `markdownlint-cli` sources: <https://github.com/igorshubovych/markdownlint-cli>
&& npm install -g --production "markdownlint-cli@${MARKDOWN_CLI_VERSION}" \
# `ncc` sources: <https://github.com/vercel/ncc>
&& npm install -g --production "@vercel/[email protected]"
# prepare "file system structure" for runtime
RUN set -x \
&& mkdir -p /tmp/rootfs/usr/local/bin
# pack `markdownlint-cli` into single file and put into required location
RUN set -x \
&& ncc build /usr/local/lib/node_modules/markdownlint-cli --minify --no-cache --out /tmp/markdownlint-cli-packed \
&& mv /tmp/markdownlint-cli-packed/index.js /tmp/rootfs/usr/local/bin/markdownlint
# copy additional image files
COPY ./docker-entrypoint.sh /tmp/rootfs/docker-entrypoint.sh
COPY ./lint /tmp/rootfs/lint
# Image hub: <https://hub.docker.com/r/mhart/alpine-node>, sources: <https://github.com/mhart/alpine-node>
FROM mhart/alpine-node:slim-12 as runtime
LABEL \
# Docs: <https://github.com/opencontainers/image-spec/blob/master/annotations.md>
org.opencontainers.image.title="Markdown linter" \
org.opencontainers.image.description="Markdown linter with rules and settings presetts" \
org.opencontainers.image.url="https://github.com/avto-dev/markdown-lint" \
org.opencontainers.image.source="https://github.com/avto-dev/markdown-lint" \
org.opencontainers.image.vendor="avto-dev" \
org.opencontainers.image.licenses="MIT"
# copy all files from builder as a single layer
COPY --from=builder /tmp/rootfs /
RUN set -x \
# create node user and group
&& addgroup -g 1000 node \
&& adduser -u 1000 -G node -s /bin/sh -D node \
# setup files owner
&& chown -R node:node /lint \
# install required for image dependencies
&& apk add --no-cache bash \
&& /usr/local/bin/markdownlint --version
ENTRYPOINT ["/docker-entrypoint.sh"]