Skip to content

Commit c99f76e

Browse files
committed
Add Konflux Dockerfiles
1 parent 85da881 commit c99f76e

File tree

30 files changed

+4357
-0
lines changed

30 files changed

+4357
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
####################
2+
# base #
3+
####################
4+
FROM registry.access.redhat.com/ubi9/python-311:latest AS base
5+
6+
WORKDIR /opt/app-root/bin
7+
8+
# OS Packages needs to be installed as root
9+
USER 0
10+
11+
# Install useful OS packages
12+
RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
13+
14+
# Other apps and tools installed as default user
15+
USER 1001
16+
17+
# Install micropipenv to deploy packages from Pipfile.lock
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]"
19+
20+
# Install the oc client
21+
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/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+
27+
####################
28+
# codeserver #
29+
####################
30+
FROM base AS codeserver
31+
32+
ARG TARGETOS TARGETARCH
33+
34+
ARG CODESERVER_SOURCE_CODE=codeserver/ubi9-python-3.11
35+
ARG CODESERVER_VERSION=v4.98.0
36+
37+
LABEL name="odh-notebook-code-server-ubi9-python-3.11" \
38+
summary="code-server image with python 3.11 based on UBI 9" \
39+
description="code-server image with python 3.11 based on UBI9" \
40+
io.k8s.display-name="code-server image with python 3.11 based on UBI9" \
41+
io.k8s.description="code-server image with python 3.11 based on UBI9" \
42+
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
43+
io.openshift.build.commit.ref="main" \
44+
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/codeserver/ubi9-python-3.11" \
45+
io.openshift.build.image="quay.io/opendatahub/workbench-images:codeserver-ubi9-python-3.11"
46+
47+
USER 0
48+
49+
WORKDIR /opt/app-root/bin
50+
51+
# Install useful OS packages
52+
RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
53+
54+
# Install code-server
55+
RUN yum install -y "https://github.com/coder/code-server/releases/download/${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION/v/}-${TARGETARCH}.rpm" && \
56+
yum -y clean all --enablerepo='*'
57+
58+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/
59+
60+
# Create and intall the extensions though build-time on a temporary directory. Later this directory will copied on the `/opt/app-root/src/.local/share/code-server/extensions` via run-code-server.sh file when it starts up.
61+
RUN mkdir -p /opt/app-root/extensions-temp && \
62+
code-server --install-extension /opt/app-root/bin/utils/ms-python.python-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp && \
63+
code-server --install-extension /opt/app-root/bin/utils/ms-toolsai.jupyter-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp
64+
65+
# Install NGINX to proxy code-server and pass probes check
66+
ENV NGINX_VERSION=1.24 \
67+
NGINX_SHORT_VER=124 \
68+
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
69+
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
70+
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
71+
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
72+
NGINX_APP_ROOT=${APP_ROOT} \
73+
NGINX_LOG_PATH=/var/log/nginx \
74+
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl
75+
76+
# Modules does not exist
77+
RUN yum install -y https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
78+
INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl fcgiwrap initscripts chkconfig supervisor" && \
79+
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
80+
rpm -V $INSTALL_PKGS && \
81+
yum -y clean all --enablerepo='*'
82+
83+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
84+
85+
# Copy extra files to the image.
86+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/nginx/root/ /
87+
88+
# Changing ownership and user rights to support following use-cases:
89+
# 1) running container on OpenShift, whose default security model
90+
# is to run the container under random UID, but GID=0
91+
# 2) for working root-less container with UID=1001, which does not have
92+
# to have GID=0
93+
# 3) for default use-case, that is running container directly on operating system,
94+
# with default UID and GID (1001:0)
95+
# Supported combinations of UID:GID are thus following:
96+
# UID=1001 && GID=0
97+
# UID=<any>&& GID=0
98+
# UID=1001 && GID=<any>
99+
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
100+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
101+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
102+
mkdir -p ${NGINX_APP_ROOT}/api/ && \
103+
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
104+
mkdir -p ${NGINX_LOG_PATH} && \
105+
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
106+
chown -R 1001:0 ${NGINX_CONF_PATH} && \
107+
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
108+
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
109+
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
110+
chmod ug+rw ${NGINX_CONF_PATH} && \
111+
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
112+
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
113+
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
114+
rpm-file-permissions && \
115+
# Ensure the temporary directory and target directory have the correct permissions
116+
mkdir -p /opt/app-root/src/.local/share/code-server/extensions && \
117+
mkdir -p /opt/app-root/src/.local/share/code-server/coder-logs && \
118+
chown -R 1001:0 /opt/app-root/src/.local/share/code-server && \
119+
chown -R 1001:0 /opt/app-root/extensions-temp && \
120+
chown -R 1001:0 /opt/app-root/src/.config/code-server
121+
122+
## Configure nginx
123+
COPY ${CODESERVER_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
124+
COPY ${CODESERVER_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
125+
COPY ${CODESERVER_SOURCE_CODE}/nginx/api/ /opt/app-root/api/
126+
127+
# Launcher
128+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/run-code-server.sh ${CODESERVER_SOURCE_CODE}/run-nginx.sh ./
129+
130+
ENV SHELL=/bin/bash
131+
132+
ENV PYTHONPATH=/opt/app-root/bin/python3
133+
134+
USER 1001
135+
136+
# Install useful packages from Pipfile.lock
137+
COPY ${CODESERVER_SOURCE_CODE}/Pipfile.lock ./
138+
139+
# Install packages and cleanup
140+
RUN echo "Installing softwares and packages" && \
141+
micropipenv install && \
142+
rm -f ./Pipfile.lock && \
143+
# Fix permissions to support pip in Openshift environments \
144+
chmod -R g+w /opt/app-root/lib/python3.11/site-packages && \
145+
fix-permissions /opt/app-root -P
146+
147+
WORKDIR /opt/app-root/src
148+
149+
CMD ["/opt/app-root/bin/run-code-server.sh"]
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
####################
2+
# base #
3+
####################
4+
FROM registry.access.redhat.com/ubi9/python-312:latest AS base
5+
6+
WORKDIR /opt/app-root/bin
7+
8+
# OS Packages needs to be installed as root
9+
USER 0
10+
11+
# Install useful OS packages
12+
RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
13+
14+
# Other apps and tools installed as default user
15+
USER 1001
16+
17+
# Install micropipenv to deploy packages from Pipfile.lock
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]"
19+
20+
# Install the oc client
21+
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/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+
27+
####################
28+
# codeserver #
29+
####################
30+
FROM base AS codeserver
31+
32+
ARG TARGETOS TARGETARCH
33+
34+
ARG CODESERVER_SOURCE_CODE=codeserver/ubi9-python-3.12
35+
ARG CODESERVER_VERSION=v4.98.0
36+
37+
LABEL name="odh-notebook-code-server-ubi9-python-3.12" \
38+
summary="code-server image with python 3.12 based on UBI 9" \
39+
description="code-server image with python 3.12 based on UBI9" \
40+
io.k8s.display-name="code-server image with python 3.12 based on UBI9" \
41+
io.k8s.description="code-server image with python 3.12 based on UBI9" \
42+
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
43+
io.openshift.build.commit.ref="main" \
44+
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/codeserver/ubi9-python-3.12" \
45+
io.openshift.build.image="quay.io/opendatahub/workbench-images:codeserver-ubi9-python-3.12"
46+
47+
USER 0
48+
49+
WORKDIR /opt/app-root/bin
50+
51+
# Install useful OS packages
52+
RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
53+
54+
# Install code-server
55+
RUN yum install -y "https://github.com/coder/code-server/releases/download/${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION/v/}-${TARGETARCH}.rpm" && \
56+
yum -y clean all --enablerepo='*'
57+
58+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/
59+
60+
# Create and intall the extensions though build-time on a temporary directory. Later this directory will copied on the `/opt/app-root/src/.local/share/code-server/extensions` via run-code-server.sh file when it starts up.
61+
RUN mkdir -p /opt/app-root/extensions-temp && \
62+
code-server --install-extension /opt/app-root/bin/utils/ms-python.python-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp && \
63+
code-server --install-extension /opt/app-root/bin/utils/ms-toolsai.jupyter-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp
64+
65+
# Install NGINX to proxy code-server and pass probes check
66+
ENV NGINX_VERSION=1.24 \
67+
NGINX_SHORT_VER=124 \
68+
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
69+
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
70+
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
71+
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
72+
NGINX_APP_ROOT=${APP_ROOT} \
73+
NGINX_LOG_PATH=/var/log/nginx \
74+
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl
75+
76+
# Modules does not exist
77+
RUN yum install -y https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
78+
INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl fcgiwrap initscripts chkconfig supervisor" && \
79+
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
80+
rpm -V $INSTALL_PKGS && \
81+
yum -y clean all --enablerepo='*'
82+
83+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
84+
85+
# Copy extra files to the image.
86+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/nginx/root/ /
87+
88+
# Changing ownership and user rights to support following use-cases:
89+
# 1) running container on OpenShift, whose default security model
90+
# is to run the container under random UID, but GID=0
91+
# 2) for working root-less container with UID=1001, which does not have
92+
# to have GID=0
93+
# 3) for default use-case, that is running container directly on operating system,
94+
# with default UID and GID (1001:0)
95+
# Supported combinations of UID:GID are thus following:
96+
# UID=1001 && GID=0
97+
# UID=<any>&& GID=0
98+
# UID=1001 && GID=<any>
99+
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
100+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
101+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
102+
mkdir -p ${NGINX_APP_ROOT}/api/ && \
103+
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
104+
mkdir -p ${NGINX_LOG_PATH} && \
105+
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
106+
chown -R 1001:0 ${NGINX_CONF_PATH} && \
107+
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
108+
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
109+
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
110+
chmod ug+rw ${NGINX_CONF_PATH} && \
111+
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
112+
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
113+
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
114+
rpm-file-permissions && \
115+
# Ensure the temporary directory and target directory have the correct permissions
116+
mkdir -p /opt/app-root/src/.local/share/code-server/extensions && \
117+
mkdir -p /opt/app-root/src/.local/share/code-server/coder-logs && \
118+
chown -R 1001:0 /opt/app-root/src/.local/share/code-server && \
119+
chown -R 1001:0 /opt/app-root/extensions-temp && \
120+
chown -R 1001:0 /opt/app-root/src/.config/code-server
121+
122+
## Configure nginx
123+
COPY ${CODESERVER_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
124+
COPY ${CODESERVER_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
125+
COPY ${CODESERVER_SOURCE_CODE}/nginx/api/ /opt/app-root/api/
126+
127+
# Launcher
128+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/run-code-server.sh ${CODESERVER_SOURCE_CODE}/run-nginx.sh ./
129+
130+
ENV SHELL=/bin/bash
131+
132+
ENV PYTHONPATH=/opt/app-root/bin/python3
133+
134+
USER 1001
135+
136+
# Install useful packages from Pipfile.lock
137+
COPY ${CODESERVER_SOURCE_CODE}/Pipfile.lock ./
138+
139+
# Install packages and cleanup
140+
RUN echo "Installing softwares and packages" && \
141+
micropipenv install && \
142+
rm -f ./Pipfile.lock && \
143+
# Fix permissions to support pip in Openshift environments \
144+
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
145+
fix-permissions /opt/app-root -P
146+
147+
WORKDIR /opt/app-root/src
148+
149+
CMD ["/opt/app-root/bin/run-code-server.sh"]

0 commit comments

Comments
 (0)