Skip to content

Commit ccb09d9

Browse files
committed
Dockerfile: update to python 3.4.3 for example/flask_demo.mochi to work
Using pyenv to lay down the ground to have multiples versions of python in the same image so the image can be used for testing.
1 parent dccf396 commit ccb09d9

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

Dockerfile

+26-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,35 @@ MAINTAINER Long Vu "[email protected]"
44

55
RUN locale-gen en_US.UTF-8 && \
66
apt-get update && \
7-
apt-get install -y python-virtualenv python3-dev libzmq3-dev && \
8-
virtualenv -p /usr/bin/python3 /venv/mochi && \
9-
. /venv/mochi/bin/activate && \
10-
LANG=en_US.UTF-8 pip3 install mochi flask Flask-RESTful Pillow && \
7+
apt-get install -y curl git make g++ libbz2-dev libreadline-dev libssl-dev libsqlite3-dev python3-dev libzmq3-dev && \
118
useradd mochiuser --create-home
129

10+
# best-practice: run as user, not root to avoid security exploit
11+
USER mochiuser
12+
13+
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer > $HOME/pyenv-installer && \
14+
bash $HOME/pyenv-installer && \
15+
export PATH="$HOME/.pyenv/bin:$PATH" && \
16+
pyenv init - && \
17+
pyenv virtualenv-init - && \
18+
pyenv install 3.4.3 && \
19+
pyenv rehash
20+
21+
# other python versions, insert another RUN here to re-use existing cache
22+
23+
RUN export PATH="$HOME/.pyenv/bin:$PATH" && \
24+
eval "$(pyenv init -)" && \
25+
eval "$(pyenv virtualenv-init -)" && \
26+
pyenv global 3.4.3 && \
27+
pyenv virtualenv venv343mochi && \
28+
pyenv activate venv343mochi && \
29+
pip3 install --upgrade pip && \
30+
LANG=en_US.UTF-8 pip3 install mochi flask Flask-RESTful Pillow && \
31+
mkdir $HOME/workdir
32+
1333
# prevent encoding errors
1434
ENV LANG=en_US.UTF-8
1535

16-
# best-practice: run as user, not root to avoid security exploit
17-
USER mochiuser
18-
WORKDIR /home/mochiuser
36+
WORKDIR /home/mochiuser/workdir
1937

20-
ENTRYPOINT ["/venv/mochi/bin/mochi"]
38+
ENTRYPOINT ["/home/mochiuser/.pyenv/versions/venv343mochi/bin/mochi"]

0 commit comments

Comments
 (0)