docker deploy nuxtjs application error code 100 - node.js

I'm deploying NuxtJs project to live server but getting error
E: Unable to locate package tini
{"code":100,"message":"The command '/bin/sh -c apt-get update && apt-get install -y tini' returned a non-zero code: 100"}
The command '/bin/sh -c apt-get update && apt-get install -y tini' returned a non-zero code: 100
Build has failed!
Dockerfile:
FROM node:14.15.1
RUN apt-get update && apt-get install -y
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=TRUE
RUN apk add --no-cache su-exec
# create destination directory
RUN mkdir -p /usr/src/nuxt-app
WORKDIR /usr/src/nuxt-app
# update and install dependency
RUN apk update && apk upgrade
RUN apk add git
# copy the app, note .dockerignore
COPY . /usr/src/nuxt-app/
RUN npm install
RUN npm run build
EXPOSE 3000
ENV NUXT_HOST=127.0.0.1
ENV NUXT_PORT=3000
CMD \[ "npm", "start" \]
# Set any ENVs
ARG BASE_URL=${BASE_URL}
ARG BASE_URL_WITHOUT_API=${BASE_URL_WITHOUT_API}
ARG NUXT_ENV_BASE_URL=${NUXT_ENV_BASE_URL}

Related

Docker build runs 2nd stage before the 1st

I'm following this documentation to write a multi-stage build.
My Dockerfile:
FROM ubuntu:trusty
RUN apt-get update && apt-get install apt-transport-https -y
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install google-chrome-stable -y
FROM node:alpine
COPY . ./
RUN npm install
RUN npm run lighthouse
I'm trying to install Google Chrome onto the image before running Google Lighthouse. However, according to the logs, the build runs the 2nd stage first.
=> CACHED [stage-1 2/4] COPY . ./ 0.0s
=> [stage-1 3/4] RUN npm install 100.8s
=> ERROR [stage-1 4/4] RUN npm run lighthouse
Why is this happening?
They are running parallel, cause neither of the stages depend on eachother.. If you are doing this just to understand multi stage builds in docker; Here is a sample:
FROM ubuntu:trusty
RUN apt-get update && apt-get install apt-transport-https -y
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install google-chrome-stable -y
FROM someangularapp:alpine as builder
COPY . ./
RUN npm install
RUN ng build
##Above stage generates a `dist` folder in its workspace
FROM nginx:latest as deployer
COPY --from=builder /app/dist /usr/share/nginx/html/
Now whenever you run:
docker build -t someimagename --target deployer .
The builder stage executes before deployer stage... because deployer uses --from=builder which means it has a dependecy on builder stage to copy some files in this case.

How should I refactor dockerfile so it can be executed as action in ibmcloud function and any refactor for how to download allure inside container

This is my dockerfile is there any other way to install allure this won't work
sudo apt-add-repository ppa:qameta/allure
sudo apt-get update
sudo apt-get install allure
FROM ubuntu
RUN apt update
RUN apt install curl -y
RUN curl -o allure-commandline-2.17.3.tgz -Ls https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.17.3/allure-commandline-2.17.3.tgz
RUN tar -zxvf allure-commandline-2.17.3.tgz -C /opt/
RUN ln -s /opt/allure-2.17.3/bin/allure /usr/bin/allure
RUN rm -rf allure-commandline-2.17.3.tgz
RUN apt install default-jre -y
RUN apt install default-jdk -y
RUN apt install nodejs npm -y
RUN allure --version
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm","start"]

Docker with Node.js and Express.js

I'm trying to use docker with my node application, my Dockerfile looks like this:
RUN apt-get update
RUN apt-get -y install build-essential
RUN apt-get install -y nodejs
RUN apt-get install -y npm
ADD . /src
RUN cd /src && npm install
EXPOSE 8080
CMD ["node","/src/app.js"]
but after running docker build when npm install is running after trying to install https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz I get an error:
The command 'bin/sh -c /src && npm install' returned a non-zero code : 1
What can cause such an issue? I've already tried to install node-legacy instead of node and it didn't work
Try this:
# put this line on your code (if you are using ubuntu)
# this make a link from nodejs to node to add compatibility on ubuntu OS
RUN ln -s /usr/bin/nodejs /usr/bin/node
# set your current directory with WORKDIR
WORKDIR /src
RUN sudo npm install

Issue running Gulp on Docker

I have the following Dockerfile
FROM debian:jessie
MAINTAINER Ewan Valentine <ewan#theladbible.com>
WORKDIR /tmp
RUN apt-get update -y && \
apt-get install -y \
curl
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
RUN apt-get install --yes nodejs
VOLUME ["/var/www/admin/src"]
RUN mkdir -p /var/www/admin/src
WORKDIR /var/www/admin/src
RUN npm install -g gulp
ENTRYPOINT ["gulp"]
However, when I run $ docker-compose run gulp I get the following error:
[10:47:49] Local gulp not found in /var/www/admin/src
[10:47:49] Try running: npm install gulp
I'm using docker-compose and this container is linked to a volume where the source code is kept, which all runs fine otherwise.
I was liking to the wrong volume! Sorted now.

Getting "can't cd" error when when building using dockerfile

This is the complete dockerfile
FROM ubuntu:12.04
# Create directory
RUN mkdir -p /dir/subdir
# Download wget
RUN apt-get install -y wget
# Make sure package is up to date
RUN apt-get update
# Install nodejs
WORKDIR /dir
RUN wget http://nodejs.org/dist/v0.10.26/node-v0.10.26-linux-x64.tar.gz
RUN tar -zxf node-v0.10.26-linux-x64.tar.gz
RUN cd /node-v0.10.26-linux-x64 && ./configure
RUN cd /node-v0.10.26-linux-x64 && make
RUN cd /node-v0.10.26-linux-x64 && make install
# Update again
RUN apt-get-update
# Copy all the files
ADD dir/subdir dir/subdir
EXPOSE 8080
CMD ["node", "/dir/subdir/index.js"]
This is part of the log where it gets an error
Step 6 : RUN tar -zxf node-v0.10.26-linux-x64.tar.gz
---> Running in xxxxxxx
---> xxxxxxxxxxxxxx
Removing intermediate container xxxxxxxxxxxx
Step 7 : RUN cd /node-v0.10.26-linux-x64 && ./configure
---> Running in xxxxxxxx
[91m/bin/sh: 1: cd: can't cd to /node-v0.10.26-linux-x64
[0m
The command [/bin/sh -c cd /node-v0.10.26-linux-x64 && ./configure] returned a non-zero code: 2
Does anyone know what the error 2 means and how to fix it?
This time I tested it.
FROM ubuntu:12.04
# Create directory
RUN mkdir -p /dir/subdir
# Make sure package is up to date
RUN apt-get update
# Install dependencies
RUN apt-get install -y build-essential openssl libssl-dev pkg-config python
# Install nodejs
WORKDIR /dir
ADD http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz /dir/
RUN tar -zxf node-v0.10.29.tar.gz
WORKDIR /dir/node-v0.10.29
RUN ./configure && make && make install
WORKDIR /dir
# Copy all the files
ADD dir/subdir dir/subdir
EXPOSE 8080
CMD ["node", "/dir/subdir/index.js"]
Docker (v1.0.0) will use WORKDIR for subsequent RUN. cd /node-v0.10.26-linux-x64 won't work as the untar occured in /dir.

Resources