build image from tarball - node.js

I create a tar archive from within my working dir
tar -chv . --exclude='build/tarball.tar' > build/tarball.tar
and would like to create an image from this
sudo docker build - < build/tarball.tar
This is my dockerfile
FROM node:8.11.3-slim
RUN apt-get update && apt-get install -y
ENV GOSU_VERSION 1.10
RUN set -x \
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
# node-user comes from node-docker-image
RUN chown -R node:node /usr/src/app
EXPOSE 8080
ENV NODE_ENV production
CMD ["gosu","node","npm","start"]
However starting the images failes because node throws an error:
Error: Cannot find module '..'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
If I create the image from the directory itself it works, why doesn't it work if I point to the tar archive?

Depending on your docker version, I think you might want to be using docker import:
docker import build/tarball.tar mynode:latest

Related

Dockerfile for Python App: ChromeDriver and Google Chrome Installation Issue

I am encountering an issue with my Dockerfile. Previously, it was working fine, but now it is throwing an error that reads "cannot connect to chrome at 127.0.0.1:53190 This version of ChromeDriver only supports Chrome version 110 Current browser version is 109.0.5414.119". I am unsure how to resolve this issue. Here is the code for my Dockerfile:
FROM python:3.9
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
rm /tmp/chromedriver_linux64.zip && \
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY ./requirements.txt .
COPY ./ .
RUN python -m pip install --upgrade pip
RUN pip install -r requirements.txt
CMD ["python","main.py"]
i am not an expert in docker,
i am a python developer,
also above dockerfile is not written by me,
i am clueless what to do

FATAL tini (7) exec /docker-entrypoint.sh failed: No such file or directory

I'm getting this error when I run my Dockerfile.
[FATAL tini (7)] exec /docker-entrypoint.sh failed: No such file or directory
The docker build command runs fine but when I try to run it I get this issue.
I have confirmed that docker-entrypoint.sh file does exist in the root via linux find -name "docker-entrypoint.sh".
It's not a permissions issue since I have set the full read/write permissions for the file via chmod 777 command.
Any idea what I'm missing here. Below is a snippet from my Dockerfile
ARG base_image_name=tomcat
ARG base_image_version=9-jdk11-openjdk-slim
FROM $base_image_name:$base_image_version
ARG component_exe
COPY docker-entrypoint.sh $component_exe /
ENV APP_ROOT=/usr/local/tomcat
ENV component_runtime=${APP_ROOT}/webapps/$component_exe
ENV APP_USER=uat
# Install all required packages and set appropriate access permissions
RUN \
apt-get -y update && \
apt-get -y upgrade && \
apt-get install jq bash ca-certificates tini && \
adduser --disabled-password --gecos "" ${APP_USER} && \
mkdir -p ${APP_ROOT}/temp && \
mkdir -p ${APP_ROOT}/bin && \
mkdir -p ${APP_ROOT}/webapps && \
chmod 777 ${APP_ROOT}/webapps && \
chown -R ${APP_USER}:root ${APP_ROOT} && \
chmod 777 /docker-entrypoint.sh && \
chmod -R g=u ${APP_ROOT} && \
find / -name *.war && \
find / -name *tini* && \
find / -name *-entrypoint.sh && \
mv /$component_exe /usr/local/tomcat/webapps && \
chown -R :root /usr/local/openjdk-11/lib/security/cacerts && \
chmod 660 /usr/local/openjdk-11/lib/security/cacerts
EXPOSE 8080/tcp
ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
# Start Tomcat Server.
CMD ["catalina.sh", "run"]

How to include shell script suite in docker file

I am trying to create a docker image for BBMAP (https://sourceforge.net/projects/bbmap/files/latest/download) shell script suite available online along with samtools and picard.jar. I was able to run samtools and picard, but for some reason I am not able to add bbmap below. Can someone please let me know what I am missing here?
I am trying to add shell scripts to bin to run them as executables.
In my docker file below, this is where I need help:
&& wget -q https://sourceforge.net/projects/bbmap/files/latest/download \
&& tar -xjvf /tmp/download \
&& cp -av /tmp/bbmap/* /usr/bin/ \
Dockerfile:
FROM openjdk:8-jre
LABEL maintainer="AN <XXX#wustl.edu>"
LABEL org.label-schema.schema-version="1.0"
# LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.name="an/samtofastq"
LABEL org.label-schema.description="Image for Reverting .bam"
ENV SAMTOOLS_VERSION 1.9
ENV PICARD_VERSION 2.20.8
WORKDIR /tmp
RUN apt-get update -y \
&& apt-get install --no-install-recommends -y \
make \
gcc \
g++ \
libz-dev \
libbz2-dev \
liblzma-dev \
ncurses-dev \
bc \
libnss-sss \
time \
&& cd /tmp \
&& wget -q https://github.com/samtools/samtools/releases/download/${SAMTOOLS_VERSION}/samtools-${SAMTOOLS_VERSION}.tar.bz2 \
&& tar xjvf samtools-${SAMTOOLS_VERSION}.tar.bz2 \
&& cd /tmp/samtools-${SAMTOOLS_VERSION}/ \
&& make \
&& cp -av /tmp/samtools-${SAMTOOLS_VERSION}/samtools /usr/bin/ \
&& wget -q -O /usr/bin/picard.jar https://github.com/broadinstitute/picard/releases/download/${PICARD_VERSION}/picard.jar \
&& wget -q https://sourceforge.net/projects/bbmap/files/latest/download \
&& tar -xjvf /tmp/download \
&& cp -av /tmp/bbmap/* /usr/bin/ \
&& ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime \
&& echo "America/Chicago" > /etc/timezone \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& apt-get clean all \
&& rm -rfv /var/lib/apt/lists/* /tmp/* /var/tmp/*
# COPY ./entrypoint.sh /usr/local/bin/
ENV PICARD /usr/bin/picard.jar
## Add ENV for Shell scripts from BBMAP
# ENV DEMUX /usr/bin/demuxbyname.sh
# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/bin/bash"]
This is the error I am getting:
tar (child): /tmp/download: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Earlier in your script, you run:
cd /tmp/samtools-${SAMTOOLS_VERSION}/
So when you run this:
wget -q https://sourceforge.net/projects/bbmap/files/latest/download
The resulting file is:
/tmp/samtools-${SAMTOOLS_VERSION}/download
That means that when you run your tar command:
tar -xjvf /tmp/download
...it doesn't find the file because it isn't in /tmp.
Either change the path on the tar command, or add a cd /tmp to your script before downloading the file. Or pass something like -O /tmp/download.tar to your wget invocation.

How to include chromedriver in gitlab CI/CD?

I have a python selenium script that needs to be run in GitLab CI/CD. Script is running perfectly in local but the only issue is of chrome driver path in gitlab.
Do I also need to add the script to download the chrome?
I am new to gitlab CI/CD.Need help!!
Thanks
Create a Dockerfile which install all the browsers and their web drivers. Create that image and call that image in gitlab to run your tests. Here is the sample dockerfile.
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y \
python3 python3-pip \
fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
libnspr4 libnss3 lsb-release xdg-utils libxss1 libdbus-glib-1-2 \
curl unzip wget \
xvfb
# install geckodriver and firefox
RUN GECKODRIVER_VERSION=`curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+'` && \
wget https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin && \
chmod +x /usr/local/bin/geckodriver && \
rm geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz
RUN FIREFOX_SETUP=firefox-setup.tar.bz2 && \
apt-get purge firefox && \
wget -O $FIREFOX_SETUP "https://download.mozilla.org/?product=firefox-latest&os=linux64" && \
tar xjf $FIREFOX_SETUP -C /opt/ && \
ln -s /opt/firefox/firefox /usr/bin/firefox && \
rm $FIREFOX_SETUP
# install chromedriver and google-chrome
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
wget https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip chromedriver_linux64.zip -d /usr/bin && \
chmod +x /usr/bin/chromedriver && \
rm chromedriver_linux64.zip
RUN CHROME_SETUP=google-chrome.deb && \
wget -O $CHROME_SETUP "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" && \
dpkg -i $CHROME_SETUP && \
apt-get install -y -f && \
rm $CHROME_SETUP
# install phantomjs
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \
tar -jxf phantomjs-2.1.1-linux-x86_64.tar.bz2 && \
cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs && \
rm phantomjs-2.1.1-linux-x86_64.tar.bz2
RUN pip3 install selenium
RUN pip3 install pyvirtualdisplay
RUN pip3 install Selenium-Screenshot
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONUNBUFFERED=1
ENV APP_HOME /usr/src/app
WORKDIR /$APP_HOME
COPY . $APP_HOME/
CMD tail -f /dev/null
CMD python3 example.py

./asinstall not found in while docker build using dockerfile?

I am trying to build docker image using docker file . The docker file will contain aerospike database creation.
RUN wget -O aerospike.tgz 'https://www.aerospike.com/download/server/latest/artifact/ubuntu18'
RUN tar -xvf aerospike.tgz
RUN cd aerospike-server-community-*-ubuntu18*
RUN ./asinstall
FROM ubuntu:18.04
RUN apt-get update && apt-get install -q -y curl python2.7 python
RUN TEMPDIR=$(mktemp -d) && \
cd $TEMPDIR && \
curl -L 'https://www.aerospike.com/download/server/latest/artifact/ubuntu18' | tar xzv --strip-components 1 && \
./asinstall && \
cd / && \
rm -rf $TEMPDIR
seems to work.

Resources