Skip to content

Commit

Permalink
ci(images): use redhat base images
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-mesureux committed Nov 26, 2024
1 parent 9f975fc commit 20bf12f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 45 deletions.
47 changes: 21 additions & 26 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

FROM node:18-buster AS web
FROM registry.access.redhat.com/ubi9/nodejs-22 AS web

ENV \
APP_ROOT=/app_root \
USER=patrick \
HOME=/home

RUN groupadd -r usersdocker && useradd -r -g usersdocker patrick
ENV APP_ROOT=/opt/app-root \
HOME=/opt/app-root \
USER=1001

WORKDIR ${APP_ROOT}
COPY --chown=${USER} ./web .
Expand All @@ -15,30 +12,28 @@ RUN npm ci
RUN npm test -- --run
RUN npm run build

FROM registry.access.redhat.com/ubi9/ubi:9.1.0-1782 AS build
FROM registry.access.redhat.com/ubi9/ubi:latest AS build

ENV \
APP_ROOT=/app_root \
USER=1004 \
HOME=/home
ENV APP_ROOT=/opt/app-root \
HOME=/opt/app-root \
USER=1001

WORKDIR ${APP_ROOT}

USER root

ENV MAVEN_VERSION 3.9.5
ENV MAVEN_DOWNLOAD_SUM 4810523ba025104106567d8a15a8aa19db35068c8c8be19e30b219a1d7e83bcab96124bf86dc424b1cd3c5edba25d69ec0b31751c136f88975d15406cab3842b
ENV MAVEN_VERSION 3.9.6
ENV MAVEN_DOWNLOAD_SUM 706f01b20dec0305a822ab614d51f32b07ee11d0218175e55450242e49d2156386483b506b3a4e8a03ac8611bae96395fd5eec15f50d3013d5deed6d1ee18224
ENV MAVEN_DIR=/opt/maven

RUN INSTALL_PKGS="java-17-openjdk java-17-openjdk-devel" && \
RUN INSTALL_PKGS="java-21-openjdk java-21-openjdk-devel" && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf -y clean all --enablerepo='*'

WORKDIR ${HOME}

RUN curl -fsSL https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz -O && \
#echo "sha512sum apache-maven-${MAVEN_VERSION}-bin.tar.gz" && \
echo "$MAVEN_DOWNLOAD_SUM apache-maven-${MAVEN_VERSION}-bin.tar.gz" | sha512sum -c - && \
tar xvfz apache-maven-${MAVEN_VERSION}-bin.tar.gz && \
mkdir -p ${MAVEN_DIR} && \
Expand All @@ -59,30 +54,31 @@ RUN rm -r /var/cache/dnf && \
rpm -V libstdc++-static && \
dnf -y clean all --enablerepo='*'

ENV JAVA_VERSION java20
ENV MANDREL_VERSION 23.0.0.0-Final
ENV MANDREL_DOWNLOAD_SUM 4b120a3272b4e637c3832b6245e100105ff07f46ad5b304f4844de5fad6b7fb7
ENV JAVA_VERSION java21
ENV MANDREL_VERSION 23.1.0.0-Final
ENV MANDREL_DOWNLOAD_SUM 49b5a7672c542a5636a92abc2bae53ab024207261f45766774b77ee44e40ba82
ENV MANDREL_DIR /opt/mandrel

WORKDIR ${APP_ROOT}

RUN curl -fsSL https://github.com/graalvm/mandrel/releases/download/mandrel-${MANDREL_VERSION}/mandrel-${JAVA_VERSION}-linux-amd64-${MANDREL_VERSION}.tar.gz -O && \
echo "$MANDREL_DOWNLOAD_SUM mandrel-${JAVA_VERSION}-linux-amd64-${MANDREL_VERSION}.tar.gz" | sha256sum -c - && \
tar xvfz mandrel-${JAVA_VERSION}-linux-amd64-${MANDREL_VERSION}.tar.gz && \
rm mandrel-${JAVA_VERSION}-linux-amd64-${MANDREL_VERSION}.tar.gz && \
mv mandrel-${JAVA_VERSION}-${MANDREL_VERSION} mandrel && \
rm -Rf mandrel/demo mandrel/man
mv mandrel-${JAVA_VERSION}-${MANDREL_VERSION} ${MANDREL_DIR} && \
rm -Rf ${MANDREL_DIR}/demo ${MANDREL_DIR}/man

ENV JAVA_HOME=${APP_ROOT}/mandrel
ENV GRAALVM_HOME=${APP_ROOT}/mandrel
ENV PATH=${JAVA_HOME}/bin:${PATH}
ENV JAVA_HOME=${MANDREL_DIR}
ENV GRAALVM_HOME=${MANDREL_DIR}
ENV PATH=${JAVA_HOME}/bin:${MAVEN_DIR}/bin:${PATH}

COPY --chown=${USER} ./api .
RUN rm -Rf ./src/main/resources/META-INF/resources
COPY --chown=${USER} --from=web ${APP_ROOT}/dist ./src/main/resources/META-INF/resources

RUN mvn package -Pnative -B

FROM registry.access.redhat.com/ubi9/ubi-minimal:9.1.0-1793 AS runtime
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS runtime

ENV \
APP_ROOT=/app_root \
Expand All @@ -96,4 +92,3 @@ EXPOSE 8080
USER ${USER}

CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Xms40m", "-Xmx60m", "-Xmn20m"]

28 changes: 9 additions & 19 deletions job/dailyclean/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@

FROM registry.access.redhat.com/ubi8/ubi:8.5-200 as build
FROM registry.access.redhat.com/ubi9/python-312 as build

ENV \
APP_ROOT=/opt/app-root \
# The $HOME is not set by default, but some applications needs this variable
HOME=/opt/app-root \
PATH=/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV APP_ROOT=/opt/app-root

WORKDIR ${APP_ROOT}

RUN INSTALL_PKGS="python38 python38-devel python38-setuptools python38-pip gcc diffutils file make gcc-c++ cmake git" && \
dnf -y module enable python38:3.8 && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf -y clean all --enablerepo='*'

RUN python3 -m pip install --compile --no-cache-dir --root ${APP_ROOT}/packages kubernetes
RUN echo $(ls -1 ${APP_ROOT})
RUN mv ${APP_ROOT}/packages/${APP_ROOT}/* ${APP_ROOT}/packages && rm -rf ${APP_ROOT}/packages/opt

FROM registry.access.redhat.com/ubi8-minimal:8.5-204 as run
FROM registry.access.redhat.com/ubi9-minimal:latest as run

ENV \
APP_ROOT=/opt/app-root \
# The $HOME is not set by default, but some applications needs this variable
HOME=/opt/app-root \
PATH=/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PATH=/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN INSTALL_PKGS="python38" && \
RUN INSTALL_PKGS="python3.12" && \
microdnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
microdnf -y clean all --enablerepo='*'

ENV PYTHONPATH=${APP_ROOT}/.local/lib64/python3.8/site-packages
ENV PYTHONPATH=${APP_ROOT}/.local/lib64/python3.12/site-packages

WORKDIR ${APP_ROOT}

COPY --chown=1001 --from=build ${APP_ROOT}/packages/usr/local ./.local
COPY --chown=1001 --from=build ${APP_ROOT}/packages ./.local
COPY --chown=1001 dailyclean.py ${APP_ROOT}

ENTRYPOINT ["/usr/bin/python3", "dailyclean.py"]
ENTRYPOINT ["/usr/bin/python3.12", "dailyclean.py"]

0 comments on commit 20bf12f

Please sign in to comment.