1
- ARG BASE_IMAGE
2
- FROM ${BASE_IMAGE}
1
+ #####################
2
+ # base #
3
+ #####################
4
+ FROM registry.redhat.io/rhel9/python-311:latest AS base
3
5
6
+ WORKDIR /opt/app-root/bin
7
+
8
+ # Install micropipenv to deploy packages from Pipfile.lock
9
+ RUN pip install --no-cache-dir -U "micropipenv[toml]"
10
+
11
+ # OS Packages needs to be installed as root
12
+ USER root
13
+
14
+ # Install usefull OS packages
15
+ RUN dnf install -y mesa-libGL && dnf clean all && rm -rf /var/cache/yum
16
+
17
+ # Other apps and tools installed as default user
18
+ USER 1001
19
+
20
+ # Install the oc client
21
+ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/openshift-client-linux.tar.gz \
22
+ -o /tmp/openshift-client-linux.tar.gz && \
23
+ tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
24
+ rm -f /tmp/openshift-client-linux.tar.gz
25
+
26
+ WORKDIR /opt/app-root/src
27
+
28
+ #####################
29
+ # rstudio #
30
+ #####################
31
+ FROM base AS rstudio
32
+
33
+ ARG RSTUDIO_SOURCE_CODE=rstudio/rhel9-python-3.11
4
34
# Access the client's secret for the subscription manager from the environment variable
5
35
ARG SECRET_DIR=/opt/app-root/src/.sec
6
36
ARG SERVERURL_DEFAULT=""
@@ -18,7 +48,7 @@ LABEL name="odh-notebook-rstudio-server-rhel9-python-3.11" \
18
48
19
49
USER 0
20
50
21
- # uncomment the bellow line if you fall on this error: subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.
51
+ # uncomment the below line if you fall on this error: subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.
22
52
#RUN sed -i 's/\(def in_container():\)/\1\n return False/g' /usr/lib64/python*/*-packages/rhsm/config.py
23
53
24
54
# Run the subscription manager command using the provided credentials. Only include --serverurl and --baseurl if they are provided
@@ -49,11 +79,11 @@ RUN yum install -y yum-utils && \
49
79
50
80
# set R library to default (used in install.r from littler)
51
81
RUN chmod -R a+w /usr/lib64/R/library
52
- ENV LIBLOC /usr/lib64/R/library
82
+ ENV LIBLOC= /usr/lib64/R/library
53
83
54
84
# set User R Library path
55
85
RUN mkdir -p /opt/app-root/bin/Rpackages/4.4 && chmod -R a+w /opt/app-root/bin/Rpackages/4.4
56
- ENV R_LIBS_USER /opt/app-root/bin/Rpackages/4.4
86
+ ENV R_LIBS_USER= /opt/app-root/bin/Rpackages/4.4
57
87
58
88
WORKDIR /tmp/
59
89
@@ -66,7 +96,7 @@ RUN wget --progress=dot:giga https://download2.rstudio.org/server/rhel9/x86_64/r
66
96
# Specific RStudio config and fixes
67
97
RUN chmod 1777 /var/run/rstudio-server && \
68
98
mkdir -p /usr/share/doc/R
69
- COPY rstudio/rhel9-python-3.11 /rsession.conf /etc/rstudio/rsession.conf
99
+ COPY ${RSTUDIO_SOURCE_CODE} /rsession.conf /etc/rstudio/rsession.conf
70
100
71
101
# package installation
72
102
# install necessary texlive-framed package to make Knit R markup to PDF rendering possible
@@ -94,10 +124,10 @@ RUN yum -y module enable nginx:$NGINX_VERSION && \
94
124
nginx -v 2>&1 | grep -qe "nginx/$NGINX_VERSION\." && echo "Found VERSION $NGINX_VERSION" && \
95
125
yum -y clean all --enablerepo='*'
96
126
97
- COPY --chown=1001:0 rstudio/rhel9-python-3.11 /supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
127
+ COPY --chown=1001:0 ${RSTUDIO_SOURCE_CODE} /supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
98
128
99
129
# Copy extra files to the image.
100
- COPY rstudio/rhel9-python-3.11 /nginx/root/ /
130
+ COPY ${RSTUDIO_SOURCE_CODE} /nginx/root/ /
101
131
102
132
# Changing ownership and user rights to support following use-cases:
103
133
# 1) running container on OpenShift, whose default security model
@@ -128,21 +158,30 @@ RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
128
158
rpm-file-permissions
129
159
130
160
# Configure nginx
131
- COPY rstudio/rhel9-python-3.11 /nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
132
- COPY rstudio/rhel9-python-3.11 /nginx/httpconf/ /opt/app-root/etc/nginx.d/
133
- COPY rstudio/rhel9-python-3.11 /nginx/api/ /opt/app-root/api/
161
+ COPY ${RSTUDIO_SOURCE_CODE} /nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
162
+ COPY ${RSTUDIO_SOURCE_CODE} /nginx/httpconf/ /opt/app-root/etc/nginx.d/
163
+ COPY ${RSTUDIO_SOURCE_CODE} /nginx/api/ /opt/app-root/api/
134
164
135
165
# Launcher
136
166
WORKDIR /opt/app-root/bin
137
167
138
- COPY rstudio/rhel9-python-3.11 /utils utils/
139
- COPY rstudio/rhel9-python-3.11/ run-rstudio.sh rstudio/rhel9-python-3.11/ setup_rstudio.py rstudio/rhel9-python-3.11/ rsession.sh rstudio/rhel9-python-3.11 /run-nginx.sh ./
168
+ COPY ${RSTUDIO_SOURCE_CODE} /utils utils/
169
+ COPY ${RSTUDIO_SOURCE_CODE}/ run-rstudio.sh ${RSTUDIO_SOURCE_CODE}/ setup_rstudio.py ${RSTUDIO_SOURCE_CODE}/ rsession.sh ${RSTUDIO_SOURCE_CODE} /run-nginx.sh ./
140
170
141
171
# Unregister the system
142
172
RUN subscription-manager remove --all && subscription-manager unregister && subscription-manager clean
143
173
144
- WORKDIR /opt/app-root/src
145
-
146
174
USER 1001
147
175
176
+ COPY ${RSTUDIO_SOURCE_CODE}/Pipfile.lock ./
177
+
178
+ RUN echo "Installing softwares and packages" && \
179
+ micropipenv install && \
180
+ rm -f ./Pipfile.lock && \
181
+ # Fix permissions to support pip in Openshift environments \
182
+ chmod -R g+w /opt/app-root/lib/python3.11/site-packages && \
183
+ fix-permissions /opt/app-root -P
184
+
185
+ WORKDIR /opt/app-root/src
186
+
148
187
CMD ["/opt/app-root/bin/run-rstudio.sh"]
0 commit comments