Skip to content

Commit

Permalink
[fix] docker image less then 100Mb
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Nov 12, 2017
1 parent d6430f5 commit a3eaee1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.git/
dist/
build/
env/
postgresql/
__pycache__
*.egg-info/
screenshots/
50 changes: 19 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,32 @@
FROM python:2.7-alpine
FROM alpine
MAINTAINER Mosquito <me@mosquito.su>

ENV ADDRESS=0.0.0.0
ENV PORT=80
ENV STORAGE=/usr/lib/pypi-server
ENV PYPI_SERVER_SRC=/usr/local/src/pypi-server

COPY ./ /usr/local/src

WORKDIR /usr/local/src
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
gcc \
libffi-dev \
openssl-dev \
musl-dev \
libxml2-dev \
libxslt-dev \
curl-dev \
&& pip install \
PyMySQL \
&& python setup.py install --prefix=/usr/local \
&& rm -rf /usr/local/src/{*,.*??} \
&& find /usr/local -depth \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache --virtual .pypi-server-rundeps \
$runDeps \
py-psycopg2 \
&& apk del .build-deps
RUN apk add --no-cache \
py-mysqldb \
py-psycopg2 \
py-curl \
py-openssl \
py-cffi \
py-cparser \
py-lxml

COPY ./ /tmp

RUN set -ex && \
apk add --no-cache --virtual .build-deps gcc py-pip python-dev musl-dev && \
pip list && \
pip install '/tmp' && \
apk del .build-deps

VOLUME "/usr/lib/pypi-server"

COPY docker-entrypoint.sh /entrypoint.sh
RUN rm -rf /root/.cache /var/cache/*

EXPOSE 80

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
COMMIT = $(shell git rev-parse --verify HEAD | cut -c1-8)
VERSION = $(shell python setup.py --version)

all: rpm deb docker-image
all: docker-image rpm deb

rpm: rpm-image
docker run --rm -t \
Expand Down
2 changes: 1 addition & 1 deletion pypi_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
("Dmitry Orlov", "me@mosquito.su")
]

version_info = (0, 4, 4)
version_info = (0, 4, 5)

__version__ = ".".join(map(str, version_info))
__author__ = ", ".join("{0} <{1}>".format(*author) for author in author_info)
Expand Down

0 comments on commit a3eaee1

Please sign in to comment.