From 487d77e90eb730d9b765b3a6348482a823cbc476 Mon Sep 17 00:00:00 2001 From: Gabriele De Rosa <4183824+derogab@users.noreply.github.com> Date: Fri, 26 Nov 2021 12:11:50 +0100 Subject: [PATCH] Use ALPINE version of Python as docker base image --- Dockerfile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index e09ca76..d134e23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,36 @@ -FROM python:3-slim +FROM alpine:latest # Set working space WORKDIR /usr/src/app # Install dependencies -RUN apt-get update \ - # Prevent endless waiting - && DEBIAN_FRONTEND=noninteractive \ +RUN apk update \ + # Install packages + && apk add \ + tzdata \ + build-base freetype-dev libpng-dev openblas-dev \ + python3 py3-pip py3-numpy py3-pandas py3-matplotlib \ + wkhtmltopdf \ # Set UTC as timezone && ln -snf /usr/share/zoneinfo/Europe/Rome /etc/localtime \ - # Install APT packages - && apt-get install -y --fix-missing wkhtmltopdf gfortran \ # Remove tmp files - && apt-get clean && rm -rf /tmp/* /var/tmp/* \ + && rm -rf /tmp/* /var/tmp/* \ # Add PiWheels support && echo "[global]\nextra-index-url=https://www.piwheels.org/simple" >> /etc/pip.conf \ # Upgrade PIP && python3 -m pip install --no-cache-dir --upgrade pip -# Copy and install requirements +# Copy requirements COPY requirements.txt . -RUN python3 -m pip install -r requirements.txt + +# Install requirements +RUN apk update \ + # Install tmp packages + && apk add --virtual build-deps gcc python3-dev musl-dev \ + # Install PIP packages + && python3 -m pip install --no-cache-dir -r requirements.txt \ + # Delete tmp packages + && apk del build-deps # Copy app COPY . .