Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Created July 6, 2024 23:02
Show Gist options
  • Save douglasmiranda/6bb486ad0ee8559a7ae7d0bd53be47da to your computer and use it in GitHub Desktop.
Save douglasmiranda/6bb486ad0ee8559a7ae7d0bd53be47da to your computer and use it in GitHub Desktop.
Dockerfile Alpine Python Pillow
FROM python:3.12-alpine
# Python specific settings
# sends output directly to terminal
# https://docs.python.org/3/using/cmdline.html#cmdoption-u
ENV PYTHONUNBUFFERED=1
# Python packages build dependencies
RUN apk add --no-cache --virtual .build-dependencies \
# Essentials
gcc musl-dev openssl-dev \
# Postgres python client (psycopg2) build dependency
postgresql-dev \
# Pillow / PIL build dependencies
freetype-dev jpeg-dev libwebp-dev tiff-dev libpng-dev lcms2-dev \
openjpeg-dev zlib-dev libxslt-dev libxml2-dev libffi-dev \
# Python packages run dependencies
&& apk add --no-cache \
# Pillow / PIL
freetype jpeg libwebp tiff libpng lcms2 openjpeg zlib libxslt libxml2 libffi
# Install pillow / Remove build dependencies and leave only the "run dependencies"
RUN pip install pillow && apk del .build-dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment