|
| 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"] |
0 commit comments