|
1 | | -#Start from the base image Ubuntu 18.04i |
2 | | -FROM ubuntu:18.04 |
| 1 | +# Use an official Python runtime as a parent image |
| 2 | +FROM python:2.7-slim |
3 | 3 |
|
4 | | -#Define a few environement variables |
5 | | -ENV PORT 8888 |
| 4 | +# Set the working directory to /app |
| 5 | +WORKDIR /app |
6 | 6 |
|
7 | | -# The following (especially the first) is needed to deal with .deb package |
8 | | -# tzdata, which otherwise would ask for input from the terminal |
9 | | -ENV DEBIAN_FRONTEND=noninteractive |
10 | | -ENV TZ="/usr/share/zoneinfo/Europe/Stockholm" |
11 | | -RUN echo $TZ > /etc/timezone |
| 7 | +# Copy the current directory contents into the container at /app |
| 8 | +COPY . /app |
12 | 9 |
|
13 | | -### Install .deb packages |
14 | | -# apt_packages.list must contain one package per line with an optional comment. The package name *** must be followed by a TAB *** before the comment |
15 | | -COPY apt_packages.list / |
16 | | -RUN apt-get update 1>/dev/null && apt-get install -y `cat /apt_packages.list | awk -F'\t' '($1!~/^#/) && ($1!~/^$/) {print $1}' ` 1> /dev/null && apt-get clean && rm -rf /var/lib/apt/lists/* |
| 10 | +# Install any needed packages specified in requirements.txt |
| 11 | +RUN pip install --trusted-host pypi.python.org -r requirements.txt |
17 | 12 |
|
18 | | -#Install Python and JupyterLab |
19 | | -RUN python3 -m pip install --upgrade pip setuptools |
20 | | -RUN python3 -m pip install --upgrade pyzmq |
21 | | -RUN python3 -m pip install jupyterlab |
| 13 | +# Make port 80 available to the world outside this container |
| 14 | +EXPOSE 80 |
22 | 15 |
|
23 | | -#Install the Python3 kernel |
24 | | -RUN python3 -m pip install ipykernel && python3 -m ipykernel install |
| 16 | +# Define environment variable |
| 17 | +ENV NAME World |
25 | 18 |
|
26 | | -#Install extra python packages defined in the list |
27 | | -# python_packages.list describes one package per line with a structure "name_pkg-TAB-[Python2/Python3/*empty]-TAB-#Comment" |
28 | | -# An empty second columns means the package is installed in both Python2 and Python3. |
29 | | -# Python2 in the second column means that the package should be installed in python2 only. |
30 | | -# Python3 in the second column means that the package should be installed in Python3 only. |
31 | | -COPY python_packages.list / |
32 | | -RUN python3 -m pip install --upgrade `cat python_packages.list | awk -F'\t' '($1!~/^#/) && ($1!~/^$/) && (($2=="") || ($2=="Python3")) {print $1}' ` |
33 | | - |
34 | | -#Jupyter will be run rooted into that folder - mount whatever the user needs into that folder |
35 | | -RUN mkdir /data |
36 | | - |
37 | | -#Fix some folders and permissions so that the container can be run as non-root |
38 | | -RUN mkdir /.jupyter && mkdir /.local && chmod 777 /.jupyter && chmod 777 /.local |
39 | | - |
40 | | -#The command to run it all |
41 | | -CMD cd /data && /usr/local/bin/jupyter lab --port=$PORT --ip=0.0.0.0 --no-browser --allow-root --LabApp.token='' |
| 19 | +# Run app.py when the container launches |
| 20 | +CMD ["python", "app.py"] |
0 commit comments