Skip to content

Commit

Permalink
docker: switch back to debian base image
Browse files Browse the repository at this point in the history
Alpine builds are taking a very long time, possibly due to python dependencies
lacking pre-built musl wheels [1]. Moreover resulting image sizes are
comparable so benefit of alpine here is ambiguous at best.

[1] https://megamorf.gitlab.io/2020/05/06/why-it-s-better-not-to-use-alpine-linux-for-python-projects/
  • Loading branch information
mik3y committed Jul 20, 2022
1 parent 06f2682 commit b6aa68e
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3-alpine
FROM python:3.10.5-bullseye

RUN mkdir /app
WORKDIR /app
Expand All @@ -9,44 +9,49 @@ ENV SHELL=/bin/sh \
KEGBOT_IN_DOCKER=True \
KEGBOT_ENV=debug

RUN apk update && \
apk add --no-cache \
bash \
# Install toolchains. Mostly, image libraries that Python PIL/Pillow will require.
RUN apt-get -qq update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
curl \
libjpeg \
libjpeg-turbo \
openjpeg \
mariadb-connector-c-dev \
libpq && \
apk add --no-cache --virtual _build-deps \
build-base \
mariadb-dev \
postgresql-dev \
libjpeg-turbo-dev \
zlib-dev \
py-gevent \
libffi-dev \
musl-dev \
python3-dev \
openssl-dev \
cargo

RUN pip install poetry

libffi-dev \
libfreetype6-dev \
libfribidi-dev \
libharfbuzz-dev \
libjpeg-turbo-progs \
libjpeg62-turbo-dev \
liblcms2-dev \
libopenjp2-7-dev \
libtiff5-dev \
libwebp-dev \
libssl-dev \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* \
&& python -m pip install -U pip \
# The cryptography build requires rust, which adds >1GB to the image. \
# Install it only to install cryptography, then remove it. \
&& curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& pip install cryptography \
&& rm -rf /root/.rustup /root/.cargo \
&& pip install poetry \
&& rm -rf /root/.cache

# Install python dependencies.
COPY pyproject.toml poetry.lock ./
ADD pykeg/__init__.py ./pykeg/
RUN poetry config virtualenvs.create false && poetry install -n

# Install the app itself.
ADD bin ./bin
ADD pykeg ./pykeg
RUN poetry run python bin/kegbot collectstatic --noinput -v 0

# Tag the build with build information.
ARG GIT_SHORT_SHA="unknown"
ARG VERSION="unknown"
ARG BUILD_DATE="unknown"
RUN echo "GIT_SHORT_SHA=${GIT_SHORT_SHA}" > /etc/kegbot-version
RUN echo "VERSION=${VERSION}" >> /etc/kegbot-version
RUN echo "BUILD_DATE=${BUILD_DATE}" >> /etc/kegbot-version
RUN echo "GIT_SHORT_SHA=${GIT_SHORT_SHA}" \
&& echo "VERSION=${VERSION}" \
&& echo "BUILD_DATE=${BUILD_DATE}" /etc/kegbot-version

VOLUME ["/kegbot-data"]

Expand Down

0 comments on commit b6aa68e

Please sign in to comment.