pypiserver/Dockerfile
Matthew Planchard d162d660c4
Updated test & requirements filename
Thanks for your PR! I was wondering why everyone kept complaining about
`bcrypt`, when my local tests were succeeding just fine, so I spent
some time making the docker test script replicate the error.

Turns out the `.htpasswd` files I was generating were using md5, so they
were not triggering the error. The htpasswd file in this update does
use bcrypt encryption, so it triggers a 500 error on the previous
version of the Dockerfile.

I also updated the test to be a bit more thorough, validating an
authenticated upload in addition to just making sure the server is
running.

The only other change I made was to move `requirements.txt` into a more
specific `docker-requirements.txt` file, just to make it clear that its
intention is to be a part of the docker build and not the normal install
process.
2019-01-31 09:16:54 +01:00

48 lines
1.3 KiB
Docker

FROM alpine:3.8 AS 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 {} \;
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 apk add --no-cache py2-pip \
&& mkdir /install \
&& pip install --prefix=/install --requirement /requirements.txt \
&& find /install -name "*.py" ! -name "__*" -exec rm {} \;
FROM base
# 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
USER pypiserver
WORKDIR /data
EXPOSE 8080
ENTRYPOINT ["pypi-server", "-p", "8080"]
CMD ["packages"]