simplify Dockerfile

This commit is contained in:
Daniel Langbein 2022-11-20 14:19:56 +01:00
parent 9cdbbe9b16
commit c4270445a6

View File

@ -1,47 +1,21 @@
FROM python:3.10-alpine # Python image.
# - https://docs.docker.com/language/python/build-images/
FROM python:3.10-slim-buster
WORKDIR /usr/src/ WORKDIR /usr/src/
# setting the correct timezone requires "zdtata" # Set timezone.
# numpy (dependency of matplotlib) requires "make automake gcc ..." # - https://dev.to/0xbf/set-timezone-in-your-docker-image-d22
# source: https://stackoverflow.com/a/48349161/6334421 # Official Debian and Ubuntu images automatically run apt-get clean, so explicit invocation is not required.
# pillow (dependency of matplotlib) requires "zlib-dev jpeg-dev ..." # - https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
RUN apk update && \ RUN apt update && apt install tzdata -y
apk add \ ENV TZ="Europe/Berlin"
tzdata \
make automake gcc g++ subversion python3-dev \
zlib-dev jpeg-dev freetype-dev lcms2-dev libwebp-dev tcl-dev tk-dev harfbuzz-dev \
fribidi-dev libimagequant-dev libxcb-dev && \
rm -rf /var/cache/apk/*
# source: https://serverfault.com/a/683651/537998
ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN python3 -m pip install --no-cache-dir --upgrade pip
# LDFLAGS required for "pip install pillow"
# otherwise this would be necessary:
## RUN ln -s /usr/lib/x86_64-linux-gnu/libz.so /lib/
## RUN ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /lib/
# source: https://github.com/python-pillow/Pillow/issues/3103#issuecomment-382634946
ENV LDFLAGS=-L/usr/lib/x86_64-linux-gnu/
COPY requirements.txt ./ COPY requirements.txt ./
RUN python3 -m pip install --no-cache-dir --upgrade -r requirements.txt RUN pip3 install --no-cache-dir -r requirements.txt
#
# if the above fails, try using the below instead
#
#RUN python3 -m pip install --no-cache-dir --upgrade requests
#RUN python3 -m pip install --no-cache-dir --upgrade setuptools
#RUN python3 -m pip install --no-cache-dir --upgrade numpy
#RUN python3 -m pip install --no-cache-dir --upgrade pillow
#RUN python3 -m pip install --no-cache-dir --upgrade matplotlib
COPY src/ ./ COPY src/ ./
RUN chmod +x langfingaz/main.py RUN chmod +x langfingaz/main.py
# unbuffered output option otherwise script sleeps before any output appears ENTRYPOINT [ "python3", "./langfingaz/main.py" ]
# python -u
ENTRYPOINT [ "python", "./langfingaz/main.py" ]
CMD [ "log-verbose" ] CMD [ "log-verbose" ]