|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# MEGALINTER FLAVOR [formatters]: Contains only formatters |
| 3 | +########################################### |
| 4 | +########################################### |
| 5 | +## Dockerfile to run MegaLinter ## |
| 6 | +########################################### |
| 7 | +########################################### |
| 8 | + |
| 9 | +# @not-generated |
| 10 | + |
| 11 | +############################################################################################# |
| 12 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 13 | +############################################################################################# |
| 14 | +#FROM__START |
| 15 | +FROM mvdan/shfmt:latest-alpine as shfmt |
| 16 | +FROM alpine/terragrunt:latest as terragrunt |
| 17 | +#FROM__END |
| 18 | + |
| 19 | +################## |
| 20 | +# Get base image # |
| 21 | +################## |
| 22 | +FROM python:3.11.5-alpine3.18 |
| 23 | +ARG GITHUB_TOKEN |
| 24 | + |
| 25 | +############################################################################################# |
| 26 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 27 | +############################################################################################# |
| 28 | +#ARG__START |
| 29 | +ARG PSSA_VERSION='latest' |
| 30 | +#ARG__END |
| 31 | + |
| 32 | +#################### |
| 33 | +# Run APK installs # |
| 34 | +#################### |
| 35 | + |
| 36 | +WORKDIR / |
| 37 | + |
| 38 | +############################################################################################# |
| 39 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 40 | +############################################################################################# |
| 41 | +#APK__START |
| 42 | +RUN apk add --no-cache \ |
| 43 | + bash \ |
| 44 | + ca-certificates \ |
| 45 | + curl \ |
| 46 | + gcc \ |
| 47 | + git \ |
| 48 | + git-lfs \ |
| 49 | + libffi-dev \ |
| 50 | + make \ |
| 51 | + musl-dev \ |
| 52 | + openssh \ |
| 53 | + npm \ |
| 54 | + nodejs-current \ |
| 55 | + yarn \ |
| 56 | + && git config --global core.autocrlf true |
| 57 | +#APK__END |
| 58 | + |
| 59 | +# PATH for golang & python |
| 60 | +ENV GOROOT=/usr/lib/go \ |
| 61 | + GOPATH=/go |
| 62 | + # PYTHONPYCACHEPREFIX="$HOME/.cache/cpython/" NV: not working for all packages :/ |
| 63 | +# hadolint ignore=DL3044 |
| 64 | +ENV PATH="$PATH":"$GOROOT"/bin:"$GOPATH"/bin |
| 65 | +RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin || true && \ |
| 66 | + # Ignore npm package issues |
| 67 | + yarn config set ignore-engines true || true |
| 68 | + |
| 69 | +############################## |
| 70 | +# Installs rust dependencies # |
| 71 | +############################################################################################# |
| 72 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 73 | +############################################################################################# |
| 74 | + |
| 75 | +#CARGO__START |
| 76 | +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable \ |
| 77 | + && export PATH="/root/.cargo/bin:${PATH}" \ |
| 78 | + && cargo install --force --locked sarif-fmt \ |
| 79 | + && rm -rf /root/.cargo/registry /root/.cargo/git /root/.cache/sccache /root/.rustup |
| 80 | +ENV PATH="/root/.cargo/bin:${PATH}" |
| 81 | +#CARGO__END |
| 82 | + |
| 83 | +################################ |
| 84 | +# Installs python dependencies # |
| 85 | +############################################################################################# |
| 86 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 87 | +############################################################################################# |
| 88 | + |
| 89 | +#PIPVENV__START |
| 90 | +RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtualenv \ |
| 91 | + && mkdir -p "/venvs/black" && cd "/venvs/black" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir black && deactivate && cd ./../.. \ |
| 92 | + && mkdir -p "/venvs/isort" && cd "/venvs/isort" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir isort black && deactivate && cd ./../.. \ |
| 93 | + && mkdir -p "/venvs/rstfmt" && cd "/venvs/rstfmt" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir rstfmt && deactivate && cd ./../.. \ |
| 94 | + && mkdir -p "/venvs/snakefmt" && cd "/venvs/snakefmt" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir snakefmt && deactivate && cd ./../.. \ |
| 95 | + && find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf && rm -rf /root/.cache |
| 96 | +ENV PATH="${PATH}":/venvs/black/bin:/venvs/isort/bin:/venvs/rstfmt/bin:/venvs/snakefmt/bin |
| 97 | +#PIPVENV__END |
| 98 | + |
| 99 | +############################ |
| 100 | +# Install NPM dependencies # |
| 101 | +############################################################################################# |
| 102 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 103 | +############################################################################################# |
| 104 | + |
| 105 | +ENV NODE_OPTIONS="--max-old-space-size=8192" \ |
| 106 | + NODE_ENV=production |
| 107 | +#NPM__START |
| 108 | +WORKDIR /node-deps |
| 109 | +RUN npm --no-cache install --ignore-scripts --omit=dev \ |
| 110 | + prettier \ |
| 111 | + markdownlint-cli \ |
| 112 | + markdown-table-formatter && \ |
| 113 | + echo "Cleaning npm cache…" \ |
| 114 | + && npm cache clean --force || true \ |
| 115 | + && echo "Changing owner of node_modules files…" \ |
| 116 | + && chown -R "$(id -u)":"$(id -g)" node_modules # fix for https://github.com/npm/cli/issues/5900 \ |
| 117 | + && echo "Removing extra node_module files…" \ |
| 118 | + && rm -rf /root/.npm/_cacache \ |
| 119 | + && find . -name "*.d.ts" -delete \ |
| 120 | + && find . -name "*.map" -delete \ |
| 121 | + && find . -name "*.npmignore" -delete \ |
| 122 | + && find . -name "*.travis.yml" -delete \ |
| 123 | + && find . -name "CHANGELOG.md" -delete \ |
| 124 | + && find . -name "README.md" -delete \ |
| 125 | + && find . -name ".package-lock.json" -delete \ |
| 126 | + && find . -name "package-lock.json" -delete \ |
| 127 | + && find . -name "README.md" -delete |
| 128 | +WORKDIR / |
| 129 | + |
| 130 | +#NPM__END |
| 131 | + |
| 132 | +# Add node packages to path # |
| 133 | +ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ |
| 134 | + NODE_PATH="/node-deps/node_modules" |
| 135 | + |
| 136 | +############################## |
| 137 | +# Installs ruby dependencies # |
| 138 | +############################################################################################# |
| 139 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 140 | +############################################################################################# |
| 141 | + |
| 142 | +#GEM__START |
| 143 | + |
| 144 | +#GEM__END |
| 145 | + |
| 146 | +############################## |
| 147 | +# COPY instructions # |
| 148 | +############################################################################################# |
| 149 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 150 | +############################################################################################# |
| 151 | + |
| 152 | +#COPY__START |
| 153 | +COPY --link --from=shfmt /bin/shfmt /usr/bin/ |
| 154 | +COPY --link --from=terragrunt /bin/terraform /usr/bin/ |
| 155 | +#COPY__END |
| 156 | + |
| 157 | +############################################################################################# |
| 158 | +## @generated by .automation/build.py using descriptor files, please do not update manually ## |
| 159 | +############################################################################################# |
| 160 | +#OTHER__START |
| 161 | +# shfmt installation |
| 162 | +# Managed with COPY --link --from=shfmt /bin/shfmt /usr/bin/ |
| 163 | + |
| 164 | +# csharpier installation |
| 165 | +RUN /usr/share/dotnet/dotnet tool install -g csharpier \ |
| 166 | + |
| 167 | +# powershell_formatter installation |
| 168 | + && pwsh -c 'Install-Module -Name PSScriptAnalyzer -RequiredVersion ${PSSA_VERSION} -Scope AllUsers -Force' |
| 169 | + |
| 170 | +# terraform-fmt installation |
| 171 | +# Managed with COPY --link --from=terragrunt /bin/terraform /usr/bin/ |
| 172 | + |
| 173 | +#OTHER__END |
| 174 | + |
| 175 | +################################ |
| 176 | +# Installs python dependencies # |
| 177 | +################################ |
| 178 | +COPY megalinter /megalinter |
| 179 | +RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ |
| 180 | + && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ |
| 181 | + && rm -rf /var/cache/apk/* \ |
| 182 | + && find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf |
| 183 | + |
| 184 | +####################################### |
| 185 | +# Copy scripts and rules to container # |
| 186 | +####################################### |
| 187 | +COPY megalinter/descriptors /megalinter-descriptors |
| 188 | +COPY TEMPLATES /action/lib/.automation |
| 189 | + |
| 190 | +# Copy server scripts |
| 191 | +COPY server /server |
| 192 | + |
| 193 | +########################### |
| 194 | +# Get the build arguments # |
| 195 | +########################### |
| 196 | +ARG BUILD_DATE |
| 197 | +ARG BUILD_REVISION |
| 198 | +ARG BUILD_VERSION |
| 199 | + |
| 200 | +################################################# |
| 201 | +# Set ENV values used for debugging the version # |
| 202 | +################################################# |
| 203 | +ENV BUILD_DATE=$BUILD_DATE \ |
| 204 | + BUILD_REVISION=$BUILD_REVISION \ |
| 205 | + BUILD_VERSION=$BUILD_VERSION |
| 206 | + |
| 207 | +#FLAVOR__START |
| 208 | +ENV MEGALINTER_FLAVOR=formatters |
| 209 | +#FLAVOR__END |
| 210 | + |
| 211 | +######################################### |
| 212 | +# Label the instance and set maintainer # |
| 213 | +######################################### |
| 214 | +LABEL com.github.actions.name="MegaLinter" \ |
| 215 | + com.github.actions.description="The ultimate linters aggregator to make sure your projects are clean" \ |
| 216 | + com.github.actions.icon="code" \ |
| 217 | + com.github.actions.color="red" \ |
| 218 | + maintainer="Nicolas Vuillamy <nicolas.vuillamy@gmail.com>" \ |
| 219 | + org.opencontainers.image.created=$BUILD_DATE \ |
| 220 | + org.opencontainers.image.revision=$BUILD_REVISION \ |
| 221 | + org.opencontainers.image.version=$BUILD_VERSION \ |
| 222 | + org.opencontainers.image.authors="Nicolas Vuillamy <nicolas.vuillamy@gmail.com>" \ |
| 223 | + org.opencontainers.image.url="https://megalinter.io" \ |
| 224 | + org.opencontainers.image.source="https://github.com/oxsecurity/megalinter" \ |
| 225 | + org.opencontainers.image.documentation="https://megalinter.io" \ |
| 226 | + org.opencontainers.image.vendor="Nicolas Vuillamy" \ |
| 227 | + org.opencontainers.image.description="Lint your code base with GitHub Actions" |
| 228 | + |
| 229 | +#EXTRA_DOCKERFILE_LINES__START |
| 230 | +COPY entrypoint.sh /entrypoint.sh |
| 231 | +RUN chmod +x entrypoint.sh |
| 232 | +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] |
| 233 | +#EXTRA_DOCKERFILE_LINES__END |
0 commit comments