forked from peeringdb/peeringdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
93 lines (65 loc) · 1.89 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
FROM python:3.7-alpine as base
ARG virtual_env=/srv/www.peeringdb.com/venv
ENV VIRTUAL_ENV="$virtual_env"
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# build container
FROM base as builder
RUN apk --update --no-cache add \
g++ \
libjpeg-turbo-dev \
linux-headers \
make \
mariadb-dev
# create venv
RUN pip install -U pip pipenv
RUN python3 -m venv "$VIRTUAL_ENV"
WORKDIR /srv/www.peeringdb.com
ADD Pipfile* ./
RUN pipenv install --ignore-pipfile
# inetd
RUN apk add busybox-extras
#### final image here
FROM base as final
ARG uid=996
# extra settings file if needed
ARG ADD_SETTINGS_FILE=mainsite/settings/dev.py
# add dependencies
RUN apk add gettext libjpeg-turbo mariadb-connector-c
RUN adduser -Du $uid pdb
WORKDIR /srv/www.peeringdb.com
COPY --from=builder "$VIRTUAL_ENV" "$VIRTUAL_ENV"
RUN mkdir -p api-cache etc locale media static var/log
COPY manage.py .
# container exec whois
COPY in.whoisd .
COPY Ctl/VERSION etc
COPY docs/ docs
COPY mainsite/ mainsite
COPY $ADD_SETTINGS_FILE mainsite/settings/
COPY peeringdb_server/ peeringdb_server
COPY fixtures/ fixtures
COPY scripts/manage /usr/bin/
# inetd for whois
COPY --from=builder /usr/sbin/inetd /usr/sbin/
COPY Ctl/docker/inetd.conf /etc/
RUN chown -R pdb:pdb api-cache locale media var/log
#### test image here
FROM final as tester
WORKDIR /srv/www.peeringdb.com
# copy from builder in case we're testing new deps
COPY --from=builder /srv/www.peeringdb.com/Pipfile* ./
COPY tests/ tests
RUN pip install -U pipenv
RUN pipenv install --dev --ignore-pipfile -v
RUN echo `which python`
RUN pip freeze
RUN pytest -v -rA --cov-report term-missing --cov=peeringdb_server tests/
#### entry point from final image, not tester
FROM final
COPY Ctl/docker/entrypoint.sh .
COPY Ctl/docker/django-uwsgi.ini etc/
ENV UWSGI_SOCKET="127.0.0.1:7002"
ENV RUNSERVER_BIND="127.0.0.1:8080"
USER pdb
ENTRYPOINT ["./entrypoint.sh"]
CMD ["runserver", "$RUNSERVER_BIND"]