How to convert Centos7 Dockerfile to Alpine

Viewed 19

I'm fairly new to Docker and I'm attempting to convert a centos7/nodejs base image to alpine/node11.
Looks like I made it halfway through the docker file.

The error that I get is /docker-entrypoint.sh: line 22: pm2-docker: not found

Here is that line "pm2-docker start /opt/server/ecosystem.config.js"

How do I install pm2 on alpine?

I came across Can not run bash script in pm2 on docker alpine image that mentioned Installing bash in alpine.

That didn't work for me. Below you will find my docker-entrypoint.sh, centos7 Dockerfile and alpine dockerfile.

I will also have to install express as well.

Any help will be appreciated.

docker-entrypoint.sh

#!/bin/sh
export APP

if [ "$APP" = "ptimes" ] 
then
   #rsync -arog --exclude='/opt/server/ecosystem.config.js' /home/server /opt/
   mkdir -p /opt/server/
   cp -R -n /home/server /opt/
   pm2-docker start /opt/server/ecosystem.config.js   -- line 22
fi

Centos Base

FROM centos7:latest

ENV NODEJS_HOME=/usr/node/node-v11.10.1-linux-x64/
ENV PATH=$NODEJS_HOME/bin:/home/node/.npm-global/bin:$PATH

ADD https://nexus-nonprod-gss.uscis.dhs.gov/nexus/repository/customer-service/node-js/node-v11.10.1-linux-x64.tar.gz /

COPY centos7-java8-node11-base/docker-entrypoint.sh /

RUN mkdir -p /usr/node \
  && mkdir -p /.pm2/bin/www \
  && chmod -R 777 /.pm2 \
  && tar -xzvf node-v11.10.1-linux-x64.tar.gz -C /usr/node \
  && rm -rf node-v11.10.1-linux-x64.tar.gz \
  && node -v \
  && npm -g install npm \
  && npm -g install pm2 \
  && npm -g config set strict-ssl false \
  && npm -g config set registry https://nexus-gss.uscis.dhs.gov/nexus/repository/npmjs-registry/ \
  && npm -g install express \
  && npm -g install console-stamp\
  && chmod 755 /docker-entrypoint.sh  
EXPOSE 8080

Alpine Node11

FROM alpine3:16

ENV NODEJS_HOME=/usr/node/node-v11.10.1-linux-x64/
ENV PATH=$NODEJS_HOME/bin:/home/node/.npm-global/bin:$PATH

ADD https://nexus-nonprod-gss.uscis.dhs.gov/nexus/repository/customer-service/node-js/node-v11.10.1-linux-x64.tar.gz /

COPY /docker-entrypoint.sh /


RUN mkdir -p /usr/node \
  && mkdir -p /.pm2/bin/www \
  && chmod -R 777 /.pm2 \
  && tar -xzvf node-v11.10.1-linux-x64.tar.gz -C /usr/node \
  && rm -rf node-v11.10.1-linux-x64.tar.gz \
  && apk add bash \
#&& apk add nodejs-current \ - Think this will give me a node version conflict as I'm using 11.
 #&& apk add npm \  -- Doesn't work
 #&& npm clean cache —force \ -- Doesn't work
 #&& npm -g install pm2 \  -- npm not recognized
 #&& apk add --update pm2 \ -- Doesn't work
 && chmod 755 /docker-entrypoint.sh  
#&& apk add --update express-generator -g  -- Doesn't work

EXPOSE 8080

0 Answers
Related