Skip to content

Commit

Permalink
Dockerfile - use multi-stage for performance increase & specific lang…
Browse files Browse the repository at this point in the history
…uage installation (#39)

* Update Dockerfile

multi staging bb

* specify bash entrypoint, remove uncessary --chmod
  • Loading branch information
aSemy committed Jul 4, 2021
1 parent 8c4d5dd commit 3b413cb
Showing 1 changed file with 23 additions and 64 deletions.
87 changes: 23 additions & 64 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 <rojo@deba.cl>"
# 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"]

0 comments on commit 3b413cb

Please sign in to comment.