Forgerock - Forgeops - util - building with RHEL? - rhel

I am trying to take this Dockerfile here - https://github.com/ForgeRock/forgeops/blob/release/6.5.0/docker/util/Dockerfile
And change the old version which is Alpine linux (seen below):
FROM alpine:3.7
...
RUN apk add --update ca-certificates \
&& apk add --update -t deps curl\
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& apk del --purge deps \
&& apk add --update jq su-exec unzip curl bash openldap-clients \
&& rm /var/cache/apk/* \
&& mkdir -p $FORGEROCK_HOME \
&& addgroup -g 11111 forgerock \
&& adduser -s /bin/bash -h "$FORGEROCK_HOME" -u 11111 -D -G forgerock forgerock
To change it to run off of RHEL 7 (my changes below)
FROM ubi7-stigd:7.6
...
# Install epel, so we can install jq later
RUN rpm --import http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 \
&& yum install -y --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Install other stuff
RUN yum -y --disableplugin=subscription-manager update \
&& yum install -y --disableplugin=subscription-manager jq su-exec unzip curl bash openldap-clients ca-certificates deps \
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& mkdir -p $FORGEROCK_HOME \
&& groupadd -g 11111 forgerock \
&& useradd -m -s /bin/bash -d "$FORGEROCK_HOME" -u 11111 -g forgerock -G root forgerock
The container builds just fine (although it complains about not being able to find "su-exec" and "deps"). But when I upload this image to my OpenShift and run it via an OpenAM pod, the container fails to start, timing out after 10 minutes. The events show that the container started, and logs only show 2 lines, saying it timed out after 10 minutes.
Anyone know what the issue might be?

I needed to install the "nc" package, as one of the .sh files uses nc.

Related

PyTorch Jupyter Notebook image unable to find torch

I have built a pytorch jupyter notebook image using the Dockerfile below. The only thing I changed from Tensorflow Jupyter Dockerfile is the base image (From Tensorflow to PyTorch).
However, when I launch the Notebook in Kubeflow, I’m unable to import torch. However, with !pip list, I can actually find the torch module. Any solutions?
ARG BASE_IMAGE=pytorch/pytorch:1.5.1-cuda10.1-cudnn7-runtime
FROM $BASE_IMAGE
ARG TF_SERVING_VERSION=0.0.0
ARG NB_USER=jovyan
# TODO: User should be refactored instead of hard coded jovyan
USER root
ENV DEBIAN_FRONTEND noninteractive
ENV NB_USER $NB_USER
ENV NB_UID 1000
ENV HOME /home/$NB_USER
ENV NB_PREFIX /
ENV PATH $HOME/.local/bin:$PATH
# Use bash instead of sh
SHELL ["/bin/bash", "-c"]
RUN apt-get update && apt-get install -yq --no-install-recommends \
apt-transport-https \
build-essential \
bzip2 \
ca-certificates \
curl \
g++ \
git \
gnupg \
graphviz \
locales \
lsb-release \
openssh-client \
sudo \
unzip \
vim \
wget \
zip \
emacs \
python3-pip \
python3-dev \
python3-setuptools \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Nodejs for jupyterlab-manager
RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
RUN apt-get update && apt-get install -yq --no-install-recommends \
nodejs \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV DOCKER_CREDENTIAL_GCR_VERSION=1.4.3
RUN curl -LO https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v${DOCKER_CREDENTIAL_GCR_VERSION}/docker-credential-gcr_linux_amd64-${DOCKER_CREDENTIAL_GCR_VERSION}.tar.gz && \
tar -zxvf docker-credential-gcr_linux_amd64-${DOCKER_CREDENTIAL_GCR_VERSION}.tar.gz && \
mv docker-credential-gcr /usr/local/bin/docker-credential-gcr && \
rm docker-credential-gcr_linux_amd64-${DOCKER_CREDENTIAL_GCR_VERSION}.tar.gz && \
chmod +x /usr/local/bin/docker-credential-gcr
# Install AWS CLI
RUN curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "/tmp/awscli-bundle.zip" && \
unzip /tmp/awscli-bundle.zip && ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \
rm -rf ./awscli-bundle
# Install Azure CLI
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null && \
AZ_REPO=$(lsb_release -cs) && \
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | tee /etc/apt/sources.list.d/azure-cli.list && \
apt-get update && \
apt-get install azure-cli
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
# Create NB_USER user with UID=1000 and in the 'users' group
# but allow for non-initial launches of the notebook to have
# $HOME provided by the contents of a PV
RUN useradd -M -s /bin/bash -N -u $NB_UID $NB_USER && \
chown -R ${NB_USER}:users /usr/local/bin && \
mkdir -p $HOME && \
chown -R ${NB_USER}:users ${HOME}
RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && \
apt-get install -y google-cloud-sdk kubectl
# Install Tini - used as entrypoint for container
RUN cd /tmp && \
wget --quiet https://github.com/krallin/tini/releases/download/v0.18.0/tini && \
echo "12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855 *tini" | sha256sum -c - && \
mv tini /usr/local/bin/tini && \
chmod +x /usr/local/bin/tini
# Install base python3 packages
RUN pip3 --no-cache-dir install \
jupyter-console==6.0.0 \
jupyterlab \
kubeflow-fairing==1.0.1
RUN docker-credential-gcr configure-docker && chown ${NB_USER}:users $HOME/.docker/config.json
# Configure container startup
EXPOSE 8888
USER jovyan
ENTRYPOINT ["tini", "--"]
CMD ["sh","-c", "jupyter notebook --notebook-dir=/home/${NB_USER} --ip=0.0.0.0 --no-browser --allow-root --port=8888 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*' --NotebookApp.base_url=${NB_PREFIX}"]

Dockerfile build fails all of a sudden

I'm trying to resolve build problems when running commands to build below dockerfile,
errors for example I get:
1.
/bin/sh: 1: /opt/conda/bin/pip: not found
The command '/bin/sh -c wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh && echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && bash /tmp/miniconda.sh -f -b -p /opt/conda && /opt/conda/bin/conda install --yes -c conda-forge python=3.5 sqlalchemy tornado jinja2 traitlets requests pip pycurl nodejs configurable-http-proxy && /opt/conda/bin/pip install --upgrade pip && rm /tmp/miniconda.sh' returned a non-zero code: 127
2.
When trying to comment the problematic part we get another issue with npm such as:
/bin/sh: 1: npm: not found
Any idea what's going on here?
Dockerfile
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
FROM debian:jessie
MAINTAINER Jupyter Project <jupyter#googlegroups.com>
# install nodejs, utf8 locale, set CDN because default httpredir is unreliable
ENV DEBIAN_FRONTEND noninteractive
RUN REPO=http://cdn-fastly.deb.debian.org && \
echo "deb $REPO/debian jessie main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list && \
apt-get -y update && \
apt-get -y upgrade && \
apt-get -y install wget locales git bzip2 &&\
/usr/sbin/update-locale LANG=C.UTF-8 && \
locale-gen C.UTF-8 && \
apt-get remove -y locales && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV LANG C.UTF-8
# install Python + NodeJS with conda
RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh && \
echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && \
bash /tmp/miniconda.sh -f -b -p /opt/conda && \
/opt/conda/bin/conda install --yes -c conda-forge \
python=3.5 sqlalchemy tornado jinja2 traitlets requests pip pycurl \
nodejs configurable-http-proxy && \
/opt/conda/bin/pip install --upgrade pip && \
rm /tmp/miniconda.sh
ENV PATH=/opt/conda/bin:$PATH
EXPOSE 8000
RUN mkdir -p /src/jupyterhub
WORKDIR /src/jupyterhub
ADD . /src/jupyterhub
RUN npm install --unsafe-perm && \
pip install . && \
rm -rf $PWD ~/.cache ~/.npm
ADD . /src/jupyterhub
LABEL org.jupyter.service="jupyterhub"
CMD ["jupyterhub"]
The latest pip package hosted by conda forge is noarch/pip-20.0.2-py_2.tar.bz2 and it has the bin folder missing hence calling /opt/conda/bin/pip will give /opt/conda/bin/pip: not found error.
I would suggest enforcing the versions of the packages to prevent updated versions causing build error, this will achieve deterministic builds in different machines which saves time on having to figure out what version change is causing the error.
In order to get pip properly, amending the Dockerfile with the below should do the trick:
RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh && \
echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && \
bash /tmp/miniconda.sh -f -b -p /opt/conda && \
/opt/conda/bin/conda install --yes -c conda-forge \
python=3.5 sqlalchemy tornado jinja2 traitlets requests pip=18.0=py35_1001 pycurl \
nodejs configurable-http-proxy && \
/opt/conda/bin/pip install --upgrade pip && \
rm /tmp/miniconda.sh

Docker image erorr bin not found after npm installation

I need to extend a Dockerfile and add grunt to it. I did the following:
This docker run as-is
FROM openjdk:8-jdk-slim
ARG ND=v12.13.0
RUN apt-get update && \
apt-get install --yes --no-install-recommends curl && \
NODE_H=/opt/nodejs; mkdir -p ${NODE_H} && \
curl --fail --silent --output - "http://nodejs.org/dist/${ND}/node-${ND}-linux-x64.tar.gz" \
| tar -xzv -f - -C "${NODE_H}" && \
ln -s "${NODE_H}/node-${ND}-linux-x64/bin/npm" /usr/local/bin/npm && \
ln -s "${NODE_H}/node-${ND}-linux-x64/bin/node" /usr/local/bin/node && \
ln -s "${NODE_H}/node-${ND}-linux-x64/bin/npx" /usr/local/bin/ && \
npm install grunt-cli -g
RUN grunt -v
I've put also the following which doesn't help...
ENV PATH="$PATH:/usr/local/bin"
When I run the command grunt-v I get the following error:
/bin/sh: 1: grunt: not found.
I try also to install grunt through npm install grunt -g without success. Any idea how to fix it?
grunt output from docker build
/opt/nodejs/node-v12.13.0-linux-x64/bin/grunt -> /opt/nodejs/node-v12.13.0-linux-x64/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli#1.3.2
I need the grunt command to be available in this docker image
I cannot change the docker image, i.e. form jdk...this is given
update
I've also tried with what VonC suggested but still have issue,
FROM openjdk:8-jdk-slim
ARG ND=v12.13.0
RUN apt-get update && \
apt-get install --yes --no-install-recommends curl && \
# install node
NODE_HOME=/opt/nodejs; mkdir -p ${NODE_HOME} && \
curl --fail --silent --output - "http://nodejs.org/dist/${ND}/node-${ND}-linux-x64.tar.gz" \
| tar -xzv -f - -C "${NODE_HOME}" && \
ln -s "${NODE_HOME}/node-${ND}-linux-x64/bin/node" /usr/local/bin/node && \
ln -s "${NODE_HOME}/node-${ND}-linux-x64/bin/npm" /usr/local/bin/npm && \
ln -s "${NODE_HOME}/node-${ND}-linux-x64/bin/npx" /usr/local/bin/ && \
npm install -g grunt-cli
ENV PATH="${PATH}:/usr/local/bin"
RUN ls /usr/local/bin/
RUN grunt -v
the ls command returns
docker-java-home
node
npm
npx
Any idea what is missing?
this will work:
FROM openjdk:8-jdk-slim
ARG ND=v12.13.0
RUN apt-get update && \
apt-get install --yes --no-install-recommends curl \
&& NODE_HOME=/opt/nodejs; mkdir -p ${NODE_HOME} \
&& curl --fail --silent --output - "http://nodejs.org/dist/${ND}/node-${ND}-linux-x64.tar.gz" \
| tar -xzv -f - -C "${NODE_HOME}" \
&& ln -s "${NODE_HOME}/node-${ND}-linux-x64/bin/node" /usr/local/bin/node \
&& ln -s "${NODE_HOME}/node-${ND}-linux-x64/bin/npm" /usr/local/bin/npm \
&& ln -s "${NODE_HOME}/node-${ND}-linux-x64/bin/npx" /usr/local/bin/ \
&& npm install --prefix /usr/local/ -g grunt-cli
ENV PATH="${PATH}:/usr/local/bin"
RUN ls /usr/local/bin
RUN grunt -v
using --prefix will tell npm to install grunt in /usr/local/bin
ls output:
Step 5/6 : RUN ls /usr/local/bin
---> Running in 96493743512d
docker-java-home
grunt
node
npm
npx
grunt -v output:
Step 6/6 : RUN grunt -v
---> Running in c6248c4fce6c
grunt-cli: The grunt command line interface (v1.3.2)
I've put also the following which doesn't help...
ENV PATH="$PATH:/usr/local/bin"
As illustrated here, that should be enough, also the exact syntax would be (to be sure)
ENV PATH="${PATH}:/usr/local/bin"
But:
make sure to add it just before your last RUN grunt
add a RUN ls /usr/local/bin/ to see if your install command worked
try and use the syntax npm instal -g grunt, instead of npm instal grunt -g
Another approach:
The Docker image openjdk:8-jdk-slim is based on debian:buster-slim
So try and install node through its installation script, as seen here:
# install node.js environment
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gnupg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_${NODEJS_VERSION}.x | bash -
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
npm install -g grunt
You can still use the same base image openjdk:8-jdk-slim, but you just extend it with a regular node installation, rather than fiddling with symbolic links.
In your case, add ENV NODEJS_VERSION 12 first.
This works
FROM openjdk:8-jdk-slim
ARG NODE_HOME=/opt/nodejs
ARG ND=v12.13.0
ENV PATH=${PATH}:${NODE_HOME}/node-${ND}-linux-x64/bin/
RUN apt-get update && \
apt-get install --yes --no-install-recommends curl && \
# install node
mkdir -p ${NODE_HOME} && \
curl --fail --silent --output - "http://nodejs.org/dist/${ND}/node-${ND}-linux-x64.tar.gz" \
| tar -xzv -f - -C "${NODE_HOME}" && \
npm install -g grunt-cli
RUN grunt -v
First, move NODE_HOME up in your dockerfile and set it as a build arg.
That way we can already set the PATH early on.
By setting the path to the node bin folder we can use all binaries in that location without manually linking each. That translates to grunt being available after installation without additional black magic.

installing nodejs before building spring boot app

So i am building a spring boot app with angular 4 front end and i need to automate the build and i am using AWS developer suite for that
i already created the pipeline that watch my repo changes and i have this buildspec.yml with following configuration
version: 0.2
phases:
install:
commands:
- sudo apt-add-repository ppa:chris-lea/node.js
- sudo apt-get -y update
- sudo apt-get -y install nodejs=7.9.0
- node -v
- sudo npm install -g #angular/cli
pre_build:
commands:
- sudo cd src/main/frontend
- sudo npm install && sudo npm run deploy-dev
- sudo cd .. && sudo cd .. && sudo cd..
build:
commands:
- echo Build started on `date`
- mvn clean install
post_build:
commands:
- mv target/ROOT.war.original ROOT.war
artifacts:
files:
- '**/*'
base-directory: 'target/ROOT'
and it's basically install nodejs and then install angular-cli to build Angular 4 after that move all dist/* to /resources/public in the spring boot and then run maven build.
my problem is I couldn't install node i tried many ways none of them worked for me , can any one help me with a second eye or have any experience with this ?
my build environment for AWS codebuild is Java8
Well , i ended up installing nodejs v7.0.0 through bash script
i used below script
set -ex \
&& for key in \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys"$key"; \
done
sudo apt-get update
wget "https://nodejs.org/download/release/v7.0.0/node-v7.0.0-linux-
x64.tar.gz" -O node-v7.0.0-linux-x64.tar.gz \
&& wget "https://nodejs.org/download/release/v7.0.0/SHASUMS256.txt.asc" -O SHASUMS256.txt.asc \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v7.0.0-linux-x64.tar.gz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xzf "node-v7.0.0-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
&& rm "node-v7.0.0-linux-x64.tar.gz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
&& rm -fr /var/lib/apt/lists/* /tmp/* /var/tmp/*
basically this script will download and install nodejs v7.0.0 for you
which i took it from here
Hi , future struggler i left some dessert for you 3>

Docker, running NVM script in a new bash shell

I have the following in my Dockerfile:
run apt-get update; \
apt-get install -y curl && \
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
Following this line of code, I need to run a command in a new bash shell so that the environment variable set from the NVM script are used.
I have tired the following to install Nodejs and it does not work:
run ["/bin/bash", "-c", "nvm install 8.7.0"]
What can I do?
It's better to use a Dockerhub repo and use it in your Dockerfile.
You can check this repositorie or this link for more repositories, please read description before choosing a repositorie.
So for example, you can add the code line below in your Dockerfile it will pull the nvm image and install it then add your app instructions.
FROM livingdocs/nvm
Or you can read their Dockerfile and use the command they used it to install nvm
ADD ./.nvmrc /app/.nvmrc
RUN bash -c '. /usr/share/nvm/nvm.sh && cd /app && nvm install && nvm alias default'
if it didn't put this one from another repositorie:
RUN sudo apt-get update && \
sudo apt-get install -y build-essential libssl-dev libmysqlclient-dev && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN curl --location https://raw.github.com/creationix/nvm/master/install.sh | sh && \
sudo /bin/bash -c "echo \"[[ -s \$HOME/.nvm/nvm.sh ]] && . \$HOME/.nvm/nvm.sh\" >> /etc/profile.d/npm.sh" && \
echo "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" >> $HOME/.bashrc

Resources