Djangoroidの奮闘記

python,django,angularJS1~三十路過ぎたプログラマーの奮闘記

miniconda3(python3)をdockerに導入してみる。

参考サイト

miniconda3-docker hub

https://hub.docker.com/r/continuumio/miniconda3/~/dockerfile/

Dockerfileを修正

Dockerfileを以下のように修正

FROM ubuntu:14.04

MAINTAINER Dockerfiles

# Install required packages and remove the apt packages cache when done.

# install for miniconda
RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \
    libglib2.0-0 libxext6 libsm6 libxrender1 \
    libgtk2.0-0 \
    git mercurial subversion

RUN apt-get update && apt-get install -y \
    git \
    python-dev \
    python-setuptools \
    nginx \
    supervisor \
    sqlite3 \
        python-pip \
  && rm -rf /var/lib/apt/lists/*

# RUN easy_install pip
# python \

# install uwsgi now because it takes a little while
RUN pip install -U pip
RUN pip install uwsgi

RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
    wget --quiet https://repo.continuum.io/miniconda/Miniconda3-4.1.11-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p /opt/conda && \
    rm ~/miniconda.sh

RUN apt-get update && apt-get install -y curl grep sed dpkg && \
    TINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o "/v.*\"" | sed 's:^..\(.*\).$:\1:'` && \
    curl -L "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" > tini.deb && \
    dpkg -i tini.deb && \
    rm tini.deb && \
    apt-get clean

# setup all the configfiles
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY nginx-app.conf /etc/nginx/sites-available/default
COPY supervisor-app.conf /etc/supervisor/conf.d/

# COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
# to prevent re-installinig (all your) dependencies when you made a change a line or two in your app.

COPY app/requirements.txt /home/docker/code/app/
RUN pip install -r /home/docker/code/app/requirements.txt

# add (the rest of) our code
COPY . /home/docker/code/

# install django, normally you would remove this step because your project would already
# be installed in the code/app/ directory
# RUN django-admin.py startproject website /home/docker/code/app/

# migrateしてみる。
RUN python /home/docker/code/app/manage.py migrate

# collectstaticの指示
RUN python /home/docker/code/app/manage.py collectstatic --noinput

ENV PATH /opt/conda/bin:$PATH

RUN conda install -y -c https://conda.anaconda.org/menpo opencv3

EXPOSE 80
CMD ["supervisord", "-n"]

これでbuild runしてみる。。。できた!cv2がimportできるかも確認しておく。

$ docker exec -it dd8d0b9444bc /bin/bash

/# python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

できた!これでpython3系でminicondaを入れられた。

次の記事では、createsuperuserの指示を出すのと、postgreの設定、RDSの設定をやってみる。