Skip to content

Commit 769f732

Browse files
committed
Crude beginnings
1 parent 292686e commit 769f732

File tree

6 files changed

+105
-121
lines changed

6 files changed

+105
-121
lines changed

Dockerfile

+42-104
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,42 @@
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

api/app.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .web import start
2+
3+
application = start.app_factory()

docker/dev+mongo.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env sh
2+
3+
mongod &
4+
MONGOD_PID=$!
5+
6+
unitd --control "*:8888" --no-daemon --log /dev/stdout

docker/unit.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"listeners": {
3+
"*:80": {
4+
"application": "scitran-core"
5+
}
6+
},
7+
8+
"applications": {
9+
"scitran-core": {
10+
"type": "python",
11+
"workers": 2,
12+
"user": "root",
13+
"group": "root",
14+
"path": "/src/core",
15+
"module": "api.app"
16+
}
17+
}
18+
}

requirements.txt

-17
This file was deleted.

setup.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from setuptools import setup, find_packages
2+
3+
install_requires = [
4+
'django >= 1.11.5',
5+
'elasticsearch==5.3.0',
6+
'enum34==1.1.6',
7+
'jsonschema==2.6.0',
8+
'Markdown==2.6.5',
9+
'pymongo==3.2',
10+
'python-dateutil==2.4.2',
11+
'pytz==2015.7',
12+
'requests==2.9.1',
13+
'rfc3987==1.3.4',
14+
'strict-rfc3339==0.7',
15+
'unicodecsv==0.9.0',
16+
'webapp2==2.5.2',
17+
'WebOb==1.5.1',
18+
'gears',
19+
]
20+
21+
dependency_links = [
22+
'git+https://github.com/flywheel-io/[email protected]#egg=gears',
23+
]
24+
25+
setup(
26+
name = 'example',
27+
version = '0.0.1',
28+
description = '',
29+
author = '',
30+
author_email = '',
31+
url = '',
32+
license = '',
33+
packages = find_packages(),
34+
dependency_links = dependency_links,
35+
install_requires = install_requires,
36+
)

0 commit comments

Comments
 (0)