From 1a96498d789db695c96d4aa88bc41e7377db2f87 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Wed, 29 Jul 2020 22:37:56 +0000 Subject: [PATCH 1/2] Update dockerfile to use python base image for build stage. The alpine image we were previously using ran into some problems. It looks like the alpine team changed package names around for some of their python 2 packages. Additionally, their use of musl instead of glibc means that no PyPI wheels work on alpine. Also, the python:2 image includes more baked-in python dependencies. This results in a faster build with dependencies that shift less. --- Dockerfile | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index f2d5f1e4..de0cf67a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,17 +8,14 @@ # * MYSQL_PASSWORD - database password (the docker entrypoint sets MYSQL_PASS to this value for app compatibility) ### Build stage, to avoid leaving dev dependencies in the final image -FROM alpine AS build +FROM python:2-slim AS build WORKDIR /build -RUN apk add --no-cache \ - py-pip \ - build-base \ - sqlite-dev \ - python-dev \ - mariadb-dev \ - linux-headers +RUN apt-get update && apt-get install -y \ + libsqlite3-dev \ + libmariadb-dev \ + build-essential RUN pip install --no-cache-dir -U pip COPY requirements.txt /build/ @@ -33,7 +30,7 @@ RUN addgroup -S django && adduser -S django -G django COPY --from=build --chown=django:django /root/.local /home/django/.local RUN apk add --no-cache \ - python \ + python2 \ mysql-client \ mariadb-connector-c \ bash From 2cb9fa9da62a71667d794b2bccc47a5a152a95de Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 30 Jul 2020 01:10:20 +0000 Subject: [PATCH 2/2] Merge upstream --- Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index de0cf67a..9441dab4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,18 +22,16 @@ COPY requirements.txt /build/ RUN pip install --user --no-cache-dir -r requirements.txt && pip install --user --no-cache-dir uwsgi ### Final image -FROM alpine +FROM python:2-slim WORKDIR /srv -RUN addgroup -S django && adduser -S django -G django +RUN useradd django COPY --from=build --chown=django:django /root/.local /home/django/.local -RUN apk add --no-cache \ - python2 \ - mysql-client \ - mariadb-connector-c \ - bash +RUN apt-get update && apt-get install -y \ + default-mysql-client \ + libmariadb3 USER django