|
1 | | -# |
2 | | -# Image used for hosting scitran core with uwsgi. |
3 | | -# |
4 | | -# Example usage is in README.md |
5 | | -# |
6 | | - |
7 | | -FROM ubuntu:14.04 |
8 | | - |
9 | | - |
10 | | -# Install pre-requisites |
11 | | -RUN apt-get update \ |
12 | | - && apt-get install -y \ |
13 | | - build-essential \ |
14 | | - ca-certificates curl \ |
15 | | - libatlas3-base \ |
16 | | - numactl \ |
17 | | - python-dev \ |
18 | | - python-pip \ |
19 | | - libffi-dev \ |
20 | | - libssl-dev \ |
21 | | - libpcre3 \ |
22 | | - libpcre3-dev \ |
23 | | - git \ |
24 | | - && rm -rf /var/lib/apt/lists/* \ |
25 | | - && pip install -U pip |
26 | | - |
27 | | - |
28 | | -# Grab gosu for easy step-down from root in a docker-friendly manner |
29 | | -# https://github.com/tianon/gosu |
30 | | -# |
31 | | -# Alternate key servers are due to reliability issues with ha.pool.sks-keyservers.net |
32 | | -RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.6/gosu-$(dpkg --print-architecture)" \ |
33 | | - && curl -o /tmp/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.6/gosu-$(dpkg --print-architecture).asc" \ |
34 | | - && export GNUPGHOME="$(mktemp -d)" \ |
35 | | - && for server in $(shuf -e ha.pool.sks-keyservers.net \ |
36 | | - hkp://p80.pool.sks-keyservers.net:80 \ |
37 | | - keyserver.ubuntu.com \ |
38 | | - hkp://keyserver.ubuntu.com:80 \ |
39 | | - pgp.mit.edu) ; do \ |
40 | | - gpg --keyserver "$server" --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \ |
41 | | - done \ |
42 | | - && gpg --batch --verify /tmp/gosu.asc /usr/local/bin/gosu \ |
43 | | - && rm -r "$GNUPGHOME" /tmp/gosu.asc \ |
44 | | - && chmod +x /usr/local/bin/gosu |
45 | | - |
46 | | - |
47 | | -# Setup environment |
48 | | -WORKDIR /var/scitran |
49 | | - |
50 | | -RUN mkdir -p \ |
51 | | - /var/scitran/config \ |
52 | | - /var/scitran/data \ |
53 | | - /var/scitran/code/api \ |
54 | | - /var/scitran/logs \ |
55 | | - /var/scitran/keys |
56 | | - |
57 | | -# Declaring a volume makes the intent to map externally explicit. This enables |
58 | | -# the contents to survive/persist across container versions, and easy access |
59 | | -# to the contents outside the container. |
60 | | -# |
61 | | -# Declaring the VOLUME in the Dockerfile guarantees the contents are empty |
62 | | -# for any new container that doesn't specify a volume map via 'docker run -v ' |
63 | | -# or similar option. |
64 | | -# |
65 | | -VOLUME /var/scitran/keys |
66 | | -VOLUME /var/scitran/data |
67 | | -VOLUME /var/scitran/logs |
68 | | - |
69 | | - |
70 | | -# Install pip modules |
71 | | -# |
72 | | -# Split this out for better cache re-use. |
73 | | -# |
74 | | -COPY requirements.txt docker/requirements-docker.txt /var/scitran/code/api/ |
75 | | - |
76 | | -RUN pip install --upgrade pip wheel setuptools \ |
77 | | - && pip install -r /var/scitran/code/api/requirements-docker.txt \ |
78 | | - && pip install -r /var/scitran/code/api/requirements.txt |
79 | | - |
80 | | -COPY tests /var/scitran/code/api/tests/ |
81 | | -RUN bash -e -x /var/scitran/code/api/tests/bin/setup-integration-tests-ubuntu.sh |
82 | | - |
83 | | - |
84 | | -# Copy full repo |
85 | | -# |
86 | | -COPY . /var/scitran/code/api/ |
87 | | - |
88 | | -COPY docker/uwsgi-entrypoint.sh /var/scitran/ |
89 | | -COPY docker/uwsgi-config.ini /var/scitran/config/ |
90 | | -COPY docker/newrelic.ini /var/scitran/config/ |
91 | | - |
92 | | - |
93 | | - |
94 | | -# Inject build information into image so the source of the container can be |
95 | | -# determined from within it. |
96 | | -ARG BRANCH_LABEL=NULL |
97 | | -ARG COMMIT_HASH=0 |
98 | | -COPY docker/inject_build_info.sh / |
99 | | -RUN /inject_build_info.sh ${BRANCH_LABEL} ${COMMIT_HASH} \ |
100 | | - && rm /inject_build_info.sh |
101 | | - |
102 | | - |
103 | | -ENTRYPOINT ["/var/scitran/uwsgi-entrypoint.sh"] |
104 | | -CMD ["uwsgi", "--ini", "/var/scitran/config/uwsgi-config.ini", "--http", "0.0.0.0:8080", "--http-keepalive", "--so-keepalive", "--add-header", "Connection: Keep-Alive" ] |
| 1 | +FROM python:2.7-alpine3.6 as build |
| 2 | + |
| 3 | +RUN apk add --no-cache build-base curl |
| 4 | + |
| 5 | +WORKDIR /src/nginx-unit |
| 6 | + |
| 7 | +RUN curl -L https://github.com/nginx/unit/archive/master.tar.gz | tar xz --strip-components 1 |
| 8 | +RUN ./configure --prefix=/usr/local --modules=lib --state=/var/local/unit --pid=/var/unit.pid --log=/var/log/unit.log \ |
| 9 | + && ./configure python \ |
| 10 | + && make install |
| 11 | + |
| 12 | + |
| 13 | +FROM python:2.7-alpine3.6 as dist |
| 14 | + |
| 15 | +RUN apk add --no-cache git |
| 16 | + |
| 17 | +COPY --from=build /usr/local/sbin/unitd /usr/local/sbin/unitd |
| 18 | +COPY --from=build /usr/local/lib/python.unit.so /usr/local/lib/python.unit.so |
| 19 | + |
| 20 | +EXPOSE 80 8080 27017 |
| 21 | + |
| 22 | +VOLUME /data/db |
| 23 | + |
| 24 | +WORKDIR /scr/core |
| 25 | + |
| 26 | +COPY . . |
| 27 | +COPY docker/unit.json /var/local/unit/conf.json |
| 28 | + |
| 29 | +RUN pip install -e . |
| 30 | + |
| 31 | +CMD ["unitd", "--control", "*:8080", "--no-daemon", "--log", "/dev/stdout"] |
| 32 | + |
| 33 | + |
| 34 | +FROM dist as testing |
| 35 | + |
| 36 | +RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community mongodb=3.4.4-r0 |
| 37 | + |
| 38 | +RUN pwd |
| 39 | + |
| 40 | +CMD ["./docker/dev+mongo.sh"] |
| 41 | + |
| 42 | +#docker run -it --rm -p 8080:80 -p 8081:8080 scitran/core:testing |
0 commit comments