forked from oxsecurity/megalinter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
420 lines (361 loc) · 18.6 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# syntax=docker/dockerfile:1
# MEGALINTER FLAVOR [salesforce]: Optimized for Salesforce based projects
###########################################
###########################################
## Dockerfile to run MegaLinter ##
###########################################
###########################################
# @not-generated
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#ARGTOP__START
# renovate: datasource=docker depName=rhysd/actionlint
ARG ACTION_ACTIONLINT_VERSION=1.7.1
# renovate: datasource=docker depName=koalaman/shellcheck
ARG BASH_SHELLCHECK_VERSION=v0.10.0
# renovate: datasource=docker depName=hadolint/hadolint
ARG DOCKERFILE_HADOLINT_VERSION=v2.12.0-alpine
# renovate: datasource=docker depName=mstruebing/editorconfig-checker
ARG EDITORCONFIG_EDITORCONFIG_CHECKER_VERSION=v3.0.1
# renovate: datasource=docker depName=ghcr.io/yannh/kubeconform
ARG KUBERNETES_KUBECONFORM_VERSION=v0.6.6-alpine
# renovate: datasource=docker depName=yoheimuta/protolint
ARG PROTOBUF_PROTOLINT_VERSION=0.49.8
# renovate: datasource=docker depName=zricethezav/gitleaks
ARG REPOSITORY_GITLEAKS_VERSION=v8.18.4
# renovate: datasource=docker depName=trufflesecurity/trufflehog
ARG REPOSITORY_TRUFFLEHOG_VERSION=3.78.2
# renovate: datasource=docker depName=
ARG SPELL_VALE_VERSION=v3.6.0
#ARGTOP__END
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#FROM__START
FROM rhysd/actionlint:${ACTION_ACTIONLINT_VERSION} as actionlint
# shellcheck is a dependency for actionlint
FROM koalaman/shellcheck:${BASH_SHELLCHECK_VERSION} as shellcheck
# Next FROM line commented because already managed by another linter
# FROM koalaman/shellcheck:${BASH_SHELLCHECK_VERSION} as shellcheck
FROM mvdan/shfmt:latest-alpine as shfmt
FROM hadolint/hadolint:${DOCKERFILE_HADOLINT_VERSION} as hadolint
FROM mstruebing/editorconfig-checker:${EDITORCONFIG_EDITORCONFIG_CHECKER_VERSION} as editorconfig-checker
FROM ghcr.io/yannh/kubeconform:${KUBERNETES_KUBECONFORM_VERSION} as kubeconform
FROM yoheimuta/protolint:${PROTOBUF_PROTOLINT_VERSION} as protolint
FROM zricethezav/gitleaks:${REPOSITORY_GITLEAKS_VERSION} as gitleaks
FROM trufflesecurity/trufflehog:${REPOSITORY_TRUFFLEHOG_VERSION} as trufflehog
FROM jdkato/vale:${SPELL_VALE_VERSION} as vale
FROM lycheeverse/lychee:latest-alpine as lychee
#FROM__END
##################
# Get base image #
##################
FROM python:3.12.4-alpine3.20
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#ARG__START
# renovate: datasource=github-tags depName=detekt/detekt
ARG DETEKT_VERSION=1.23.6
#ARG__END
# Static args
ARG GITHUB_TOKEN
####################
# Run APK installs #
####################
WORKDIR /
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#APK__START
RUN apk add --no-cache \
bash \
ca-certificates \
curl \
gcc \
git \
git-lfs \
libffi-dev \
make \
musl-dev \
openssh \
openjdk21 \
py3-pyflakes \
nodejs \
npm \
yarn \
openjdk17 \
helm \
gcompat \
libc6-compat \
libstdc++ \
libc-dev \
libxml2-dev \
libxml2-utils \
libgcc \
nodejs-current \
ruby \
ruby-dev \
ruby-bundler \
ruby-rdoc \
&& git config --global core.autocrlf true
#APK__END
# PATH for golang & python
ENV GOROOT=/usr/lib/go \
GOPATH=/go
# PYTHONPYCACHEPREFIX="$HOME/.cache/cpython/" NV: not working for all packages :/
# hadolint ignore=DL3044
ENV PATH="$PATH":"$GOROOT"/bin:"$GOPATH"/bin
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin || true && \
# Ignore npm package issues
yarn config set ignore-engines true || true
##############################
# Installs rust dependencies #
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#CARGO__START
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable \
&& export PATH="/root/.cargo/bin:${PATH}" \
&& cargo install --force --locked sarif-fmt shellcheck-sarif \
&& rm -rf /root/.cargo/registry /root/.cargo/git /root/.cache/sccache /root/.rustup
ENV PATH="/root/.cargo/bin:${PATH}"
#CARGO__END
################################
# Installs python dependencies #
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#PIPVENV__START
RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtualenv \
&& mkdir -p "/venvs/ansible-lint" && cd "/venvs/ansible-lint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ansible-lint && deactivate && cd ./../.. \
&& mkdir -p "/venvs/djlint" && cd "/venvs/djlint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir djlint && deactivate && cd ./../.. \
&& mkdir -p "/venvs/checkov" && cd "/venvs/checkov" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir packaging checkov && deactivate && cd ./../.. \
&& mkdir -p "/venvs/semgrep" && cd "/venvs/semgrep" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir semgrep && deactivate && cd ./../.. \
&& mkdir -p "/venvs/snakemake" && cd "/venvs/snakemake" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir snakemake && deactivate && cd ./../.. \
&& mkdir -p "/venvs/snakefmt" && cd "/venvs/snakefmt" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir snakefmt && deactivate && cd ./../.. \
&& mkdir -p "/venvs/proselint" && cd "/venvs/proselint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir proselint && deactivate && cd ./../.. \
&& mkdir -p "/venvs/sqlfluff" && cd "/venvs/sqlfluff" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir sqlfluff && deactivate && cd ./../.. \
&& mkdir -p "/venvs/yamllint" && cd "/venvs/yamllint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir yamllint && deactivate && cd ./../.. \
&& find /venvs \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete \
&& rm -rf /root/.cache
ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/djlint/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/snakemake/bin:/venvs/snakefmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin
#PIPVENV__END
############################
# Install NPM dependencies #
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
ENV NODE_OPTIONS="--max-old-space-size=8192" \
NODE_ENV=production
#NPM__START
WORKDIR /node-deps
RUN npm --no-cache install --ignore-scripts --omit=dev \
@salesforce/cli \
@stoplight/spectral-cli \
jscpd \
stylelint \
stylelint-config-standard \
stylelint-config-sass-guidelines \
stylelint-scss \
graphql \
graphql-schema-linter \
npm-groovy-lint \
htmlhint \
@prantlf/jsonlint \
v8r \
prettier \
npm-package-json-lint \
npm-package-json-lint-config-default \
markdownlint-cli \
markdown-link-check \
markdown-table-formatter \
@ls-lint/ls-lint \
secretlint \
@secretlint/secretlint-rule-preset-recommend \
@secretlint/secretlint-formatter-sarif \
cspell \
@ibm/tekton-lint && \
echo "Cleaning npm cache…" \
&& npm cache clean --force || true \
&& echo "Changing owner of node_modules files…" \
&& chown -R "$(id -u)":"$(id -g)" node_modules # fix for https://github.com/npm/cli/issues/5900 \
&& echo "Removing extra node_module files…" \
&& find . \( -not -path "/proc" \) -and \( -type f \( -iname "*.d.ts" -o -iname "*.map" -o -iname "*.npmignore" -o -iname "*.travis.yml" -o -iname "CHANGELOG.md" -o -iname "README.md" -o -iname ".package-lock.json" -o -iname "package-lock.json" \) -o -type d -name /root/.npm/_cacache \) -delete
WORKDIR /
#NPM__END
# Add node packages to path #
ENV PATH="/node-deps/node_modules/.bin:${PATH}" \
NODE_PATH="/node-deps/node_modules"
##############################
# Installs ruby dependencies #
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#GEM__START
RUN echo 'gem: --no-document' >> ~/.gemrc && \
gem install \
scss_lint
#GEM__END
##############################
# COPY instructions #
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#COPY__START
COPY --link --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
# shellcheck is a dependency for actionlint
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
# Next COPY line commented because already managed by another linter
# COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
COPY --link --from=shfmt /bin/shfmt /usr/bin/
COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
COPY --link --from=kubeconform /kubeconform /usr/bin/
COPY --link --from=protolint /usr/local/bin/protolint /usr/bin/
COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
COPY --link --from=trufflehog /usr/bin/trufflehog /usr/bin/
COPY --link --from=vale /bin/vale /bin/vale
COPY --link --from=lychee /usr/local/bin/lychee /usr/bin/
#COPY__END
#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#OTHER__START
# KOTLIN installation
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"
# SALESFORCE installation
# Next line commented because already managed by another linter
# ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
# Next line commented because already managed by another linter
# ENV PATH="$JAVA_HOME/bin:${PATH}"
RUN sf plugins install @salesforce/plugin-packaging \
&& echo y|sf plugins install sfdx-hardis \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache \
# actionlint installation
# Managed with COPY --link --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
# # shellcheck is a dependency for actionlint
# Managed with COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
# bash-exec installation
&& printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: File:[$1] is not executable"; exit 1; fi' > /usr/bin/bash-exec \
&& chmod +x /usr/bin/bash-exec \
# shellcheck installation
# Managed with # Next COPY line commented because already managed by another linter
# # COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
# shfmt installation
# Managed with COPY --link --from=shfmt /bin/shfmt /usr/bin/
# hadolint installation
# Managed with COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
# editorconfig-checker installation
# Managed with COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
# dotenv-linter installation
&& wget -q -O - https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s
# npm-groovy-lint installation
ENV JAVA_HOME_17=/usr/lib/jvm/java-17-openjdk
# ktlint installation
RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktlint && \
chmod a+x ktlint && \
mv "ktlint" /usr/bin/ \
# detekt installation
&& curl --retry 5 --retry-delay 5 -sSLO https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/detekt-cli-${DETEKT_VERSION}.zip && \
unzip detekt-cli-${DETEKT_VERSION}.zip && \
chmod a+x detekt-cli-${DETEKT_VERSION}/bin/* && \
chmod a+x detekt-cli-${DETEKT_VERSION}/lib/* && \
mv -n detekt-cli-${DETEKT_VERSION}/bin/* usr/bin && \
mv -n detekt-cli-${DETEKT_VERSION}/lib/* usr/lib \
# kubeconform installation
# Managed with COPY --link --from=kubeconform /kubeconform /usr/bin/
# kubescape installation
&& ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
curl --retry 5 --retry-delay 5 -sLv https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash -s -- -v v2.9.0 \
# protolint installation
# Managed with COPY --link --from=protolint /usr/local/bin/protolint /usr/bin/
# gitleaks installation
# Managed with COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
# grype installation
&& curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin \
# trivy installation
&& wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin \
# trivy-sbom installation
# Next line commented because already managed by another linter
# RUN wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
# trufflehog installation
# Managed with COPY --link --from=trufflehog /usr/bin/trufflehog /usr/bin/
# sfdx-scanner-apex installation
&& sf plugins install @salesforce/sfdx-scanner \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache \
# sfdx-scanner-aura installation
# Next line commented because already managed by another linter
# RUN sf plugins install @salesforce/sfdx-scanner \
# && npm cache clean --force || true \
# && rm -rf /root/.npm/_cacache
# sfdx-scanner-lwc installation
# Next line commented because already managed by another linter
# RUN sf plugins install @salesforce/sfdx-scanner \
# && npm cache clean --force || true \
# && rm -rf /root/.npm/_cacache
# lightning-flow-scanner installation
&& echo y|sf plugins install lightning-flow-scanner \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache
# vale installation
# Managed with COPY --link --from=vale /bin/vale /bin/vale
# lychee installation
# Managed with COPY --link --from=lychee /usr/local/bin/lychee /usr/bin/
#OTHER__END
################################
# Installs python dependencies #
################################
COPY megalinter /megalinter
RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \
&& PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \
&& rm -rf /var/cache/apk/* \
&& find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete
#######################################
# Copy scripts and rules to container #
#######################################
COPY megalinter/descriptors /megalinter-descriptors
COPY TEMPLATES /action/lib/.automation
# Copy server scripts
COPY server /server
###########################
# Get the build arguments #
###########################
ARG BUILD_DATE
ARG BUILD_REVISION
ARG BUILD_VERSION
#################################################
# Set ENV values used for debugging the version #
#################################################
ENV BUILD_DATE=$BUILD_DATE \
BUILD_REVISION=$BUILD_REVISION \
BUILD_VERSION=$BUILD_VERSION
#FLAVOR__START
ENV MEGALINTER_FLAVOR=salesforce
#FLAVOR__END
#########################################
# Label the instance and set maintainer #
#########################################
LABEL com.github.actions.name="MegaLinter" \
com.github.actions.description="The ultimate linters aggregator to make sure your projects are clean" \
com.github.actions.icon="code" \
com.github.actions.color="red" \
maintainer="Nicolas Vuillamy <nicolas.vuillamy@gmail.com>" \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.revision=$BUILD_REVISION \
org.opencontainers.image.version=$BUILD_VERSION \
org.opencontainers.image.authors="Nicolas Vuillamy <nicolas.vuillamy@gmail.com>" \
org.opencontainers.image.url="https://megalinter.io" \
org.opencontainers.image.source="https://github.com/oxsecurity/megalinter" \
org.opencontainers.image.documentation="https://megalinter.io" \
org.opencontainers.image.vendor="Nicolas Vuillamy" \
org.opencontainers.image.description="Lint your code base with GitHub Actions"
#EXTRA_DOCKERFILE_LINES__START
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
#EXTRA_DOCKERFILE_LINES__END