Skip to content

Commit c051050

Browse files
committedAug 12, 2016
chore/docker: configure docker for prebuilt analysis containers
1 parent bee26b9 commit c051050

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed
 

‎.dockerignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.egg-info
2+
.cache
3+
data/clearpond
4+
data/figures
5+
data/FreeAssociation
6+
data/MemeTracker
7+
data/notebooks
8+
docs/_build
9+
docs/data
10+
Dockerfile
11+
.git
12+
.ipynb_checkpoints
13+
**/__pycache__
14+
treetagger

‎Dockerfile

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
FROM ubuntu:16.04
2+
MAINTAINER Sébastien Lerique <sl@mehho.net>
3+
4+
# Install all the system and build dependencies.
5+
ENV PYTHON_VERSION 3.5
6+
ENV PG_VERSION 9.5
7+
RUN set -x \
8+
&& apt-get update \
9+
&& apt-get install -y --no-install-recommends \
10+
build-essential \
11+
ca-certificates \
12+
git \
13+
libfreetype6-dev \
14+
libpng12-0 \
15+
libpng12-dev \
16+
locales \
17+
pkg-config \
18+
postgresql-${PG_VERSION} \
19+
postgresql-server-dev-${PG_VERSION} \
20+
python${PYTHON_VERSION} \
21+
python${PYTHON_VERSION}-dev \
22+
python3 \
23+
python3-pip \
24+
sudo \
25+
unzip \
26+
wget \
27+
&& rm -rf /var/lib/apt/lists/*
28+
29+
# Make the "en_US.UTF-8" locale so postgres and python Click will be utf-8
30+
# enabled by default.
31+
RUN set -x \
32+
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
33+
ENV LC_ALL en_US.utf8
34+
ENV LANG en_US.utf8
35+
36+
# Set up postgres with user and analysis and test databases for brainscopypaste.
37+
RUN set -x \
38+
&& service postgresql start \
39+
&& sudo -u postgres psql -c 'create user brainscopypaste;' \
40+
&& sudo -u postgres psql -c 'create database brainscopypaste;' \
41+
&& sudo -u postgres psql -c 'alter database brainscopypaste owner to brainscopypaste;' \
42+
&& sudo -u postgres psql -c 'create database brainscopypaste_test;' \
43+
&& sudo -u postgres psql -c 'alter database brainscopypaste_test owner to brainscopypaste;' \
44+
&& sed -i 's/^\(\(local\|host\) \+all \+all \+.* \+\)\(peer\|md5\)$/\1trust/g' /etc/postgresql/${PG_VERSION}/main/pg_hba.conf
45+
46+
# Copy the originating repository, and install requirements.
47+
COPY . /home/brainscopypaste
48+
RUN set -x \
49+
&& cd /home/brainscopypaste \
50+
&& pip3 install --upgrade pip setuptools \
51+
&& pip install $(cat requirements.txt | grep "^numpy") \
52+
&& pip install -r requirements.txt \
53+
&& pip install --editable .
54+
55+
# Configure the brainscopypaste user.
56+
RUN set -x \
57+
&& useradd brainscopypaste \
58+
&& echo "brainscopypaste ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/brainscopypaste \
59+
&& chown -R brainscopypaste:brainscopypaste /home/brainscopypaste
60+
USER brainscopypaste
61+
62+
# Install treetagger and datasets.
63+
RUN set -x \
64+
&& cd /home/brainscopypaste \
65+
&& ./install_treetagger.sh \
66+
&& ./install_datasets.sh
67+
68+
# Clean up to reduce image size.
69+
RUN set -x \
70+
&& sudo rm -rf /root/.cache/pip \
71+
&& sudo apt-get purge -y --auto-remove \
72+
build-essential \
73+
ca-certificates \
74+
libfreetype6-dev \
75+
libpng12-dev \
76+
pkg-config \
77+
postgresql-server-dev-${PG_VERSION} \
78+
python${PYTHON_VERSION}-dev \
79+
python3-pip \
80+
unzip \
81+
wget
82+
83+
# Check the software runs its tests.
84+
RUN set -x \
85+
&& cd /home/brainscopypaste \
86+
&& sudo service postgresql restart \
87+
&& py.test
88+
89+
# Use the CLI tool, for easier use.
90+
CMD ["/home/brainscopypaste/dockerstart.sh"]

‎dockerstart.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Start postgres and run command.
5+
sudo service postgresql start
6+
cd /home/brainscopypaste
7+
brainscopypaste "$@"

‎install_datasets.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
# Find python3 command
5-
if which python3; then
5+
if which python3 >/dev/null 2>&1; then
66
PYTHON=python3
77
else
88
PYTHON=python

0 commit comments

Comments
 (0)
Please sign in to comment.