From 5e3d34324c51494271c4813e2466b858173a8ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Noss?= Date: Tue, 24 Dec 2019 06:36:32 +0100 Subject: [PATCH] Use python 3.6 for the Dockerfile (#284) * Use python 3.6 for the Dockerfile * Dockerfile: use explicit Alpine version * Empty commit to trigger a new CI build --- Dockerfile | 53 +++++++++++++++-------------------------- docker-requirements.txt | 1 + 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef923f9..13c27a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,48 +1,33 @@ -FROM alpine:3.8 AS base +FROM python:3.6-alpine3.10 as base + +# Copy the requirements & code and install them +# Do this in a separate image in a separate directory +# to not have all the build stuff in the final image +FROM base AS builder +RUN apk update +# Needed to build cffi +RUN apk add python-dev build-base libffi-dev +COPY . /code +RUN mkdir /install +RUN pip install --no-warn-script-location \ + --prefix=/install \ + /code --requirement /code/docker-requirements.txt + +FROM base -# Install python and modules that can't be installed via pip -# Delete the uncompiled variants to shave off ~10MB of the docker file RUN addgroup -S -g 9898 pypiserver \ && adduser -S -u 9898 -G pypiserver pypiserver \ && mkdir -p /data/packages \ && chown -R pypiserver:pypiserver /data/packages \ # Set the setgid bit so anything added here gets associated with the # pypiserver group - && chmod g+s /data/packages \ - && apk --no-cache add python py2-bcrypt py2-cffi py2-six \ - && find /usr -name "*.py" ! -name "__*" -exec rm {} \; \ - # Ensure pip is available to all further images - && apk add --no-cache py2-pip - -FROM base as builder - -# Copy the requirements and install them -# Do this in a separate image in a separate directory -# to not have all the pip stuff in the final image -COPY docker-requirements.txt /requirements.txt - -# Install python packages -RUN mkdir /install \ - && pip install --prefix=/install --requirement /requirements.txt \ - && find /install -name "*.py" ! -name "__*" -exec rm {} \; - -FROM base + && chmod g+s /data/packages # Copy the libraries installed via pip -COPY --from=builder /install /usr - -COPY . /code - -RUN apk add py2-setuptools \ - && cd code \ - && python setup.py install \ - && cd / \ - && rm -rf code - -VOLUME /data/packages +COPY --from=builder /install /usr/local USER pypiserver +VOLUME /data/packages WORKDIR /data EXPOSE 8080 - ENTRYPOINT ["pypi-server", "-p", "8080"] CMD ["packages"] diff --git a/docker-requirements.txt b/docker-requirements.txt index ca4dffb..4c668b6 100644 --- a/docker-requirements.txt +++ b/docker-requirements.txt @@ -1 +1,2 @@ passlib==1.7.1 +bcrypt==3.1.7 \ No newline at end of file