-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.ckg
128 lines (105 loc) · 4.33 KB
/
Dockerfile.ckg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#Download base image ubuntu
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
ENV LC_CTYPE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV R_BASE_VERSION 3.6.1
LABEL maintainer "Alberto Santos [email protected]"
USER root
RUN apt-get update && \
apt-get -yq dist-upgrade && \
apt-get install -yq --no-install-recommends && \
apt-get install -yq apt-utils software-properties-common && \
apt-get install -yq locales && \
apt-get install -yq wget && \
apt-get install -yq unzip && \
apt-get install -yq build-essential sqlite3 libsqlite3-dev libxml2 libxml2-dev zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libcurl4-openssl-dev && \
apt-get install -yq nginx && \
apt-get install -yq redis-server && \
apt-get install -yq git && \
apt-get install -y sudo && \
apt-get install -y net-tools && \
apt-get install -y npm nodejs && \
npm install -g configurable-http-proxy && \
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E084DAB9 && \
gpg -a --export E084DAB9 > cran.asc && \
apt-key add cran.asc && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 51716619E084DAB9 && \
echo "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/" > /etc/apt/sources.list.d/cran.list && \
apt-get update && \
apt-get install -y --no-install-recommends littler r-cran-littler r-base=${R_BASE_VERSION}* r-base-dev=${R_BASE_VERSION}* r-recommended=${R_BASE_VERSION}* && \
echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"), download.file.method = "libcurl")' >> /etc/R/Rprofile.site && \
apt-get clean all && \
rm -rf /var/lib/apt/lists/*
WORKDIR /
# Set the locale
RUN locale-gen en_US.UTF-8
# User management
RUN groupadd ckg_group && \
adduser --quiet --disabled-password --shell /bin/bash --home /home/adminhub --gecos "User" adminhub && \
echo "adminhub:adminhub" | chpasswd && \
usermod -a -G ckg_group adminhub && \
adduser --quiet --disabled-password --shell /bin/bash --home /home/ckguser --gecos "User" ckguser && \
echo "ckguser:ckguser" | chpasswd && \
usermod -a -G ckg_group ckguser && \
adduser --disabled-password --gecos '' --uid 1500 nginx && \
usermod -a -G ckg_group nginx
## Install packages
COPY /resources/R_packages.R /R_packages.R
RUN Rscript R_packages.R
# CKG Python library
RUN wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz && \
tar -xzf Python-3.7.9.tgz && \
rm -rf Python-3.7.9.tgz && \
cd /Python-3.7.9 && \
./configure && \
make altinstall && \
make install && \
cd / && \
rm -rf /Python-3.7.9
## pip upgrade
COPY ./requirements.txt .
RUN wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py && rm get-pip.py
RUN pip3 install --no-cache-dir --upgrade pip setuptools && \
pip3 install --no-cache-dir --ignore-installed jupyterhub uwsgi && \
pip3 install --no-cache-dir -r requirements.txt
### Creating CKG directory and setting up CKG
RUN mkdir /CKG
COPY --chown=nginx ckg /CKG/ckg
COPY docker_entrypoint.ckg.sh /CKG/docker_entrypoint.sh
ENV PYTHONPATH "${PYTHONPATH}:/CKG"
RUN ls -lrth /CKG
### Installation
WORKDIR /CKG
RUN python3 ckg/init.py
RUN touch log/graphdb_builder.log log/graphdb_connector.log log/report_manager.log log/analytics_factory.log
#### Directory ownership
RUN chown -R nginx .
RUN chgrp -R ckg_group .
RUN chmod 777 log/ -R
RUN ls -alrth .
RUN ls -alrth data
WORKDIR /
# JupyterHub
RUN mkdir /etc/jupyterhub
COPY /resources/jupyterhub.py /etc/jupyterhub/.
RUN cp -r /CKG/ckg/notebooks /home/adminhub/.
RUN cp -r /CKG/ckg/notebooks /home/ckguser/.
RUN chown -R adminhub /home/adminhub/notebooks
RUN chgrp -R adminhub /home/adminhub/notebooks
RUN chown -R ckguser /home/ckguser/notebooks
RUN chgrp -R ckguser /home/ckguser/notebooks
# NGINX and UWSGI
## Copy configuration file
COPY /resources/nginx.conf /etc/nginx/.
RUN chmod 777 /run/ -R && \
chmod 777 /root/ -R
## Copy the base uWSGI ini file
COPY /resources/uwsgi.ini /etc/uwsgi/apps-available/uwsgi.ini
COPY /resources/uwsgi.ini /etc/uwsgi/apps-enabled/uwsgi.ini
## Create log directory
RUN mkdir -p /var/log/uwsgi
RUN chmod +x /CKG/docker_entrypoint.sh && ln -s /CKG/docker_entrypoint.sh
# Expose ports (jupyterHub, CKG prod, CKG dev, Redis)
EXPOSE 8090 8050 5000 6379
ENTRYPOINT ["/bin/bash", "/CKG/docker_entrypoint.sh"]