0
votes

I have trouble with using dockerfile to build image.

dockerfile:

FROM node:4.4

MAINTAINER paas  

ENV NGINX_VERSION 1.11.6-1~jessie

RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \

&& echo "deb nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \

&& apt-get update \

&& apt-get install --no-install-recommends --no-install-suggests -y \

ca-certificates \

nginx=${NGINX_VERSION} \

nginx-module-xslt \

nginx-module-geoip \

nginx-module-image-filter \

nginx-module-perl \

nginx-module-njs \

gettext-base \

curl \

&& rm -rf /var/lib/apt/lists/*

RUN mkdir /etc/nginx/sites-enabled


# SSL Certificate Installation

ADD star_dar_kz.key /etc/ssl/

# ADD star_dar_kz.pem /etc/ssl/
# ADD dhparam.pem /etc/ssl/

# ADD nginx.conf /etc/nginx/
# ADD merchants.dar.kz.conf /etc/nginx/sites-enabled

COPY . /app

WORKDIR /app

RUN npm install --global gulp-cli

RUN npm install --global bower

RUN npm install

RUN bower --allow-root install

RUN gulp build --env prod

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

And after docker build, the GPG line appears as red and image creation fails. Why?

Sending build context to Docker daemon  3.072kB
Step 1/16 : FROM node:4.4
 ---> 93b396996a16
Step 2/16 : MAINTAINER Nurbek Sadykov
 ---> Using cache
 ---> e9a0bc967863
Step 3/16 : ENV NGINX_VERSION 1.11.6-1~jessie
 ---> Using cache
 ---> 3e87467bd365
Step 4/16 : RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62     && echo "deb h:/nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list     && apt-get update     && apt-get install --no-install-recommends --no-install-suggests -y                         ca-certificates                         nginx=${NGINX_VERSION}                         nginx-module-xslt                         nginx-module-geoip                         nginx-module-image-filter                         nginx-module-perl                         nginx-module-njs                         gettext-base                                                 curl     && rm -rf /var/lib/apt/lists/*
 ---> Running in 93f88784bc24
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.acoVZ86x3m --no-auto-check-trustdb --trust-model always --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-squeeze-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-squeeze-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-stable.gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
**gpg: requesting key 7BD9BF62 from hkp server pgp.mit.edu**
**gpg: key 7BD9BF62: public key "nginx signing key " imported**
**gpg: Total number processed: 1**
**gpg:               imported: 1  (RSA: 1)** - ** THIS IS INDICATED IN RED COLOR**
Get:1 url InRelease [63.1 kB]
Get:2 url InRelease [2865 B]
Ign url jessie InRelease
Get:3 url jessie-updates InRelease [145 kB]
Get:4 url amd64 Packages [37.3 kB]
Get:5 url jessie Release.gpg [2373 B]
Get:6 urljessie Release [148 kB]
Get:7 url amd64 Packages [613 kB]
Get:8 url amd64 Packages [23.2 kB]
Get:9 url jessie/main amd64 Packages [9063 kB]
Fetched 10.1 MB in 5s (1835 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
**Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
 distribution that some required packages have not yet been created
or been moved out of Incoming**.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nginx-module-geoip : Depends: nginx (= 1.13.7-1~jessie)
 nginx-module-image-filter : Depends: nginx (= 1.13.7-1~jessie)
 nginx-module-njs : Depends: nginx (= 1.13.7-1~jessie)
 nginx-module-perl : Depends: nginx (= 1.13.7-1~jessie)
 nginx-module-xslt : Depends: nginx (= 1.13.7-1~jessie)
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62     && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list     && apt-get update     && apt-get install --no-install-recommends --no-install-suggests -y                         ca-certificates                         nginx=${NGINX_VERSION}                         nginx-module-xslt                         nginx-module-geoip                         nginx-module-image-filter                         nginx-module-perl                         nginx-module-njs                         gettext-base                                                 curl     && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
1
Hi @Joom187, please clean up your question by using code blocks for your Dockerfile.bluescores

1 Answers

0
votes

There were three issues in your Dockerfile:

  1. Incorrect url to nginx packages
  2. Nginx modules should be the same version as nginx
  3. There is no version 1.11.6-1~jessie for module nginx-module-njs, so we need to add one more ENV variable.

The final Dockerfile is:

FROM node:4.4

MAINTAINER paas  

ENV NGINX_VERSION 1.11.6-1~jessie
ENV NGINX_MODULE_NJS 1.11.6.0.1.4-2~jessie

RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
&& echo 'deb http://nginx.org/packages/mainline/debian/ jessie nginx' >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
nginx=${NGINX_VERSION} \
nginx-module-xslt=${NGINX_VERSION} \
nginx-module-geoip=${NGINX_VERSION} \
nginx-module-image-filter=${NGINX_VERSION} \
nginx-module-perl=${NGINX_VERSION} \
nginx-module-njs=${NGINX_MODULE_NJS} \
gettext-base \
curl \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir /etc/nginx/sites-enabled

# SSL Certificate Installation 
ADD star_dar_kz.key /etc/ssl/

# ADD star_dar_kz.pem /etc/ssl/
# ADD dhparam.pem /etc/ssl/

# ADD nginx.conf /etc/nginx/
# ADD merchants.dar.kz.conf /etc/nginx/sites-enabled

COPY . /app

WORKDIR /app

RUN npm install --global gulp-cli

RUN npm install --global bower

RUN npm install

RUN bower --allow-root install

RUN gulp build --env prod

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]