2019-01-30 09:20:58 +01:00
|
|
|
FROM alpine:3.8 AS base
|
2015-10-26 23:58:03 +01:00
|
|
|
|
2019-01-30 09:20:58 +01:00
|
|
|
# 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 \
|
2018-06-27 03:51:32 +02:00
|
|
|
# Set the setgid bit so anything added here gets associated with the
|
|
|
|
# pypiserver group
|
2019-01-30 09:20:58 +01:00
|
|
|
&& chmod g+s /data/packages \
|
|
|
|
&& apk --no-cache add python py2-bcrypt py2-cffi py2-six \
|
2019-11-11 01:11:39 +01:00
|
|
|
&& find /usr -name "*.py" ! -name "__*" -exec rm {} \; \
|
|
|
|
# Ensure pip is available to all further images
|
|
|
|
&& apk add --no-cache py2-pip
|
2019-01-30 09:20:58 +01:00
|
|
|
|
|
|
|
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
|
2019-01-31 02:58:47 +01:00
|
|
|
COPY docker-requirements.txt /requirements.txt
|
2019-01-30 09:20:58 +01:00
|
|
|
|
|
|
|
# Install python packages
|
2019-11-11 01:11:39 +01:00
|
|
|
RUN mkdir /install \
|
2019-01-30 09:20:58 +01:00
|
|
|
&& 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
|
2018-06-27 03:51:32 +02:00
|
|
|
|
|
|
|
VOLUME /data/packages
|
|
|
|
USER pypiserver
|
2015-10-26 23:58:03 +01:00
|
|
|
WORKDIR /data
|
2018-06-27 03:51:32 +02:00
|
|
|
EXPOSE 8080
|
2015-10-26 23:58:03 +01:00
|
|
|
|
2018-06-27 03:51:32 +02:00
|
|
|
ENTRYPOINT ["pypi-server", "-p", "8080"]
|
|
|
|
CMD ["packages"]
|