1+ ARG BUILD_ENV=prod
12ARG BASE=registry.access.redhat.com/ubi9/ubi:9.5-1732804088
2- FROM $BASE
3+
4+ FROM $BASE as build_prod
5+ ONBUILD COPY ./requirements/requirements_ubi9.txt /root/requirements_ubi9.txt
6+
7+ FROM $BASE as build_test
8+ ONBUILD COPY ./requirements/requirements_ubi.in /root/requirements_ubi.in
9+
10+ FROM $BASE as build_custom
11+ ONBUILD COPY ./requirements/requirements.in /root/requirements.in
12+
13+ FROM build_${BUILD_ENV}
14+
15+ ARG BUILD_ENV
16+ ARG BASE
317
418LABEL com.ibm.name="IBM Storage Scale bridge for Grafana"
519LABEL com.ibm.vendor="IBM"
@@ -26,11 +40,9 @@ ENV GID=$GROUPID
2640
2741ARG HTTPPROTOCOL=http
2842ENV PROTOCOL=$HTTPPROTOCOL
29- RUN echo "the HTTP/S protocol is set to $PROTOCOL"
3043
3144ARG HTTPBASICAUTH=True
3245ENV BASICAUTH=$HTTPBASICAUTH
33- RUN echo "the HTTP/S basic authentication is set to $BASICAUTH"
3446
3547ARG AUTHUSER=None
3648ENV BASICAUTHUSER=$AUTHUSER
@@ -40,15 +52,12 @@ ENV BASICAUTHPASSW=$AUTHPASSW
4052
4153ARG HTTPPORT=None
4254ENV PORT=$HTTPPORT
43- RUN echo "the OpentTSDB API HTTP/S port is set to $PORT"
4455
4556ARG PROMPORT=None
46- ENV PROMETHEUS=$PROMPORT
47- RUN echo "the Prometheus API HTTPS port is set to $PROMETHEUS"
57+ ENV PROMETHEUS=$PROMPORT
4858
4959ARG PERFMONPORT=9980
5060ENV SERVERPORT=$PERFMONPORT
51- RUN echo "the PERFMONPORT port is set to $SERVERPORT"
5261
5362ARG CERTPATH='/etc/bridge_ssl/certs'
5463ENV TLSKEYPATH=$CERTPATH
@@ -67,27 +76,33 @@ ENV APIKEYVALUE=$KEYVALUE
6776
6877ARG PMCOLLECTORIP=0.0.0.0
6978ENV SERVER=$PMCOLLECTORIP
70- RUN echo "the pmcollector server ip is set to $SERVER"
7179
7280ARG DEFAULTLOGPATH='/var/log/ibm_bridge_for_grafana'
7381ENV LOGPATH=$DEFAULTLOGPATH
74- RUN echo "the log will use $LOGPATH"
7582
7683ARG DEFAULTLOGLEVEL=15
7784ENV LOGLEVEL=$DEFAULTLOGLEVEL
7885
79- COPY ./requirements/requirements_ubi9.txt /root/requirements_ubi9.txt
80- # COPY ./requirements/requirements_ubi.in /root/requirements_ubi.in
81-
82- RUN yum install -y python39 python3-pip
83-
84- # RUN /usr/bin/python3 -m pip install pip-tools && \
85- # /usr/bin/python3 -m piptools compile /root/requirements_ubi.in --output-file /root/requirements_ubi9.txt && \
86- # echo "Compiled python packages: $(cat /root/requirements_ubi9.txt)"
87-
88- RUN /usr/bin/python3 -m pip install -r /root/requirements_ubi9.txt && \
89- echo "Installed python version: $(/usr/bin/python3 -V)" && \
90- echo "Installed python packages: $(/usr/bin/python3 -m pip list)"
86+ RUN echo "the HTTP/S protocol is set to $PROTOCOL" && \
87+ echo "the HTTP/S basic authentication is set to $BASICAUTH" && \
88+ echo "the OpentTSDB API HTTP/S port is set to $PORT" && \
89+ echo "the Prometheus API HTTPS port is set to $PROMETHEUS" && \
90+ echo "the PERFMONPORT port is set to $SERVERPORT" && \
91+ echo "the pmcollector server ip is set to $SERVER" && \
92+ echo "the log will use $LOGPATH"
93+
94+ RUN if [ $(expr "$BASE" : '.*python.*' ) -eq 0 ]; then \
95+ yum install -y python39 python3-pip; \
96+ if [ "$BUILD_ENV" = "build_test" ]; then \
97+ python3 -m pip install pip-tools && \
98+ python3 -m piptools compile /root/requirements_ubi.in --output-file /root/requirements_ubi9.txt && \
99+ echo "Compiled python packages: $(cat /root/requirements_ubi9.txt)" ; fi && \
100+ python3 -m pip install -r /root/requirements_ubi9.txt && \
101+ echo "Installed python version: $(python3 -V)" && \
102+ echo "Installed python packages: $(python3 -m pip list)" ; else \
103+ echo "Already using python container as base image. No need to install it." && \
104+ python3 -m pip install -r /root/requirements.in && \
105+ echo "Installed python packages: $(python3 -m pip list)" ; fi
91106
92107USER root
93108
@@ -101,8 +116,8 @@ COPY ./source/gpfsConfig/mmsdrfs* /var/mmfs/gen/
101116COPY ./source/gpfsConfig/ZIMon* /opt/IBM/zimon/
102117
103118RUN if [ "${APIKEYVALUE:0:1}" = "/" ]; then ln -s $APIKEYVALUE /etc/perfmon-api-keys; echo "APIKEYVALUE is a PATH" ; else echo "APIKEYVALUE not a PATH" ; fi && \
104- if [ -z "$TLSKEYPATH" ] || [ -z "$TLSCERTFILE" ] || [ -z "$TLSKEYFILE" ] && [ "$PROTOCOL" = "https" ]; then echo "TLSKEYPATH FOR SSL CONNECTION NOT SET - ERROR" ; exit 1; else echo "PASS" ; fi
105- RUN echo "the ssl certificates path is set to $TLSKEYPATH"
119+ if [ -z "$TLSKEYPATH" ] || [ -z "$TLSCERTFILE" ] || [ -z "$TLSKEYFILE" ] && [ "$PROTOCOL" = "https" ]; then echo "TLSKEYPATH FOR SSL CONNECTION NOT SET - ERROR" ; exit 1; else echo "PASS" ; fi && \
120+ echo "the ssl certificates path is set to $TLSKEYPATH"
106121
107122# Switch to the working directory
108123WORKDIR /opt/IBM/bridge
0 commit comments