Skip to content

Commit d7bc355

Browse files
authored
Merge pull request doccano#373 from CatalystCode/hadolint-fix-pr
Add linter for Dockerfile
2 parents d77859f + ff99787 commit d7bc355

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
!.coveragerc
66
!.flake8
77
!requirements.txt
8+
!Dockerfile
89

910
app/**/bundle/
1011
app/**/node_modules/

Dockerfile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
ARG PYTHON_VERSION="3.6"
22
FROM python:${PYTHON_VERSION}-stretch AS builder
33

4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5+
46
ARG NODE_VERSION="8.x"
7+
# hadolint ignore=DL3008
58
RUN curl -sL "https://deb.nodesource.com/setup_${NODE_VERSION}" | bash - \
69
&& apt-get install --no-install-recommends -y \
710
nodejs
811

12+
ARG HADOLINT_VERSION=v1.17.1
13+
RUN curl -fsSL "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-$(uname -m)" -o /usr/local/bin/hadolint \
14+
&& chmod +x /usr/local/bin/hadolint
15+
916
COPY tools/install-mssql.sh /doccano/tools/install-mssql.sh
1017
RUN /doccano/tools/install-mssql.sh --dev
1118

1219
COPY app/server/static/package*.json /doccano/app/server/static/
13-
RUN cd /doccano/app/server/static \
14-
&& npm ci
20+
WORKDIR /doccano/app/server/static
21+
RUN npm ci
1522

1623
COPY requirements.txt /
1724
RUN pip install -r /requirements.txt \
1825
&& pip wheel -r /requirements.txt -w /deps
1926

27+
COPY Dockerfile /
28+
RUN hadolint /Dockerfile
29+
2030
COPY . /doccano
2131

2232
WORKDIR /doccano
2333
RUN tools/ci.sh
2434

2535
FROM builder AS cleaner
2636

27-
RUN cd /doccano/app/server/static \
28-
&& SOURCE_MAP=False DEBUG=False npm run build \
37+
WORKDIR /doccano/app/server/static
38+
RUN SOURCE_MAP=False DEBUG=False npm run build \
2939
&& rm -rf components pages node_modules .*rc package*.json webpack.config.js
3040

31-
RUN cd /doccano \
32-
&& python app/manage.py collectstatic --noinput
41+
WORKDIR /doccano
42+
RUN python app/manage.py collectstatic --noinput
3343

3444
FROM python:${PYTHON_VERSION}-slim-stretch AS runtime
3545

@@ -39,6 +49,7 @@ RUN /doccano/tools/install-mssql.sh
3949
RUN useradd -ms /bin/sh doccano
4050

4151
COPY --from=builder /deps /deps
52+
# hadolint ignore=DL3013
4253
RUN pip install --no-cache-dir /deps/*.whl
4354

4455
COPY --from=cleaner --chown=doccano:doccano /doccano /doccano

0 commit comments

Comments
 (0)