Skip to content

Commit d6430f5

Browse files
authored
Merge pull request #18 from 25th-floor/pr/build_in_docker
Use docker as it is supposed to be used for building from source
2 parents f2e72a7 + 4ff32f3 commit d6430f5

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

.dockerignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
*
2-
!dist/*.rpm
1+
.git/
2+
dist/
3+
build/

Dockerfile

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
FROM centos:centos7
2-
3-
COPY dist/pypi-server*.rpm /tmp/
4-
RUN yum localinstall -y /tmp/*.rpm
5-
RUN mkdir -p /usr/lib/pypi-server
6-
RUN yum clean all && rm -fr /tmp/*
1+
FROM python:2.7-alpine
2+
MAINTAINER Mosquito <me@mosquito.su>
73

84
ENV ADDRESS=0.0.0.0
95
ENV PORT=80
106
ENV STORAGE=/usr/lib/pypi-server
117

8+
COPY ./ /usr/local/src
9+
10+
WORKDIR /usr/local/src
11+
RUN set -ex \
12+
&& apk add --no-cache --virtual .build-deps \
13+
gcc \
14+
libffi-dev \
15+
openssl-dev \
16+
musl-dev \
17+
libxml2-dev \
18+
libxslt-dev \
19+
curl-dev \
20+
&& pip install \
21+
PyMySQL \
22+
&& python setup.py install --prefix=/usr/local \
23+
&& rm -rf /usr/local/src/{*,.*??} \
24+
&& find /usr/local -depth \
25+
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
26+
-exec rm -rf '{}' + \
27+
&& runDeps="$( \
28+
scanelf --needed --nobanner --recursive /usr/local \
29+
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
30+
| sort -u \
31+
| xargs -r apk info --installed \
32+
| sort -u \
33+
)" \
34+
&& apk add --no-cache --virtual .pypi-server-rundeps \
35+
$runDeps \
36+
py-psycopg2 \
37+
&& apk del .build-deps
38+
1239
VOLUME "/usr/lib/pypi-server"
1340

14-
ENTRYPOINT /usr/bin/pypi-server
41+
COPY docker-entrypoint.sh /entrypoint.sh
42+
43+
EXPOSE 80
1544

45+
ENTRYPOINT ["/entrypoint.sh"]

docker-entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
# if command starts with an option or something that is not executable, prepend pypi-server
4+
if [ "${1:0:1}" = '-' ] || ! which "${1}" >/dev/null; then
5+
set -- pypi-server "$@"
6+
fi
7+
8+
exec "$@"

0 commit comments

Comments
 (0)