diff --git a/Dockerfile b/Dockerfile index d6c8f48e..594b2d99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,8 @@ -FROM python:3.9.5-slim +# default are English and German +ARG SPELLCHECK_LANGS="en,de" + +# Builder stage: configure env vars, labels, add plain files, install common packages +FROM python:3.9.5-slim as spellcheck-builder LABEL "com.github.actions.name"="Spellcheck Action" LABEL "com.github.actions.description"="Check spelling of files in repo" @@ -7,73 +11,28 @@ LABEL "com.github.actions.color"="green" LABEL "repository"="http://github.com/rojopolis/spellcheck-github-actions" LABEL "homepage"="http://github.com/actions" LABEL "maintainer"="rojopolis " +# label as builder stage, for easy cleanup (e.g. `docker image prune --filter label=stage=builder`) +LABEL stage=builder -RUN apt-get update \ - && apt-get install -y --no-install-recommends aspell \ - #aspell-am \ - #aspell-ar \ - #aspell-bg \ - #aspell-bn \ - #aspell-br \ - #aspell-ca \ - #aspell-cs \ - #aspell-cy \ - #aspell-da \ - aspell-de \ - #aspell-el \ - aspell-en \ - #aspell-eo \ - #aspell-es \ - #aspell-et \ - #aspell-eu \ - #aspell-fa \ - #aspell-fo \ - #aspell-fr \ - #aspell-ga \ - #aspell-gl-minimos \ - #aspell-gu \ - #aspell-he \ - #aspell-hi \ - #aspell-hr \ - #aspell-hsb \ - #aspell-hu \ - #aspell-hy \ - #aspell-is \ - #aspell-it \ - #aspell-kk \ - #aspell-kn \ - #aspell-ku \ - #aspell-lt \ - #aspell-lv \ - #aspell-ml \ - #aspell-mr \ - #aspell-nl \ - #aspell-no \ - #aspell-or \ - #aspell-pa \ - #aspell-pl \ - #aspell-pt-br \ - #aspell-pt-pt \ - #aspell-ro \ - #aspell-ru \ - #aspell-sk \ - #aspell-sl \ - #aspell-ta \ - #aspell-te \ - #aspell-sv \ - #aspell-tl \ - #aspell-uk \ - #aspell-uz \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - +COPY entrypoint.sh /entrypoint.sh COPY requirements.txt /requirements.txt +COPY spellcheck.yaml /spellcheck.yaml +RUN pip3 install -r /requirements.txt -RUN pip3 install -r requirements.txt +# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get +RUN apt-get update && apt-get install -y \ + aspell \ + && rm -rf /var/lib/apt/lists/* -COPY spellcheck.yaml /spellcheck.yaml +###################################################################################################### -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +# Custom built images with an arg +FROM spellcheck-builder as spellcheck + +RUN apt-get update && apt-get install -y \ + # split arg SPELLCHECK_LANGS to space separated, and prepend each with 'aspell-' + $(echo "$SPELLCHECK_LANGS" | sed 's/,/ /g' | xargs printf -- 'aspell-%s\n') \ + && rm -rf /var/lib/apt/lists/* WORKDIR /tmp -ENTRYPOINT ["/entrypoint.sh"] +ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]