0

I am using Strapi and making the docker build of the same but I am trying to run the build I am facing nginx error.

: No such file or directoryline 2: /usr/sbin/nginx npm ERR! missing script: develop

this is my docker file

FROM armdocker.confidencial.se/proj-ldc/common_base_os_release/sles:3.37.0-5
LABEL maintainer="ken@confidencial.com"
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

ENV NODE_VERSION 14.20.0

RUN zypper addrepo -C -G -f https://arm.rnd.confidencial.se/artifactory/proj 
local/common_base_os/sles/3.37.0-5?ssl_verify=no COMMON_BASE_OS_SLES_REPO && \
zypper --non-interactive install -y shadow curl glibc-locale && \
groupadd --gid 101 -r node && \
useradd --uid 101 -r -m -g 101 -s /bin/nologin node && \
zypper clean

RUN GNUPGHOME="$(mktemp -d)" && \
export GNUPGHOME && \
NGINX_KEY="${GNUPGHOME}"/nginx_signing.key && \
curl -k -o "${NGINX_KEY}" https://nginx.org/keys/nginx_signing.key && \
rpmkeys --import "${NGINX_KEY}" && \
zypper addrepo --gpgcheck --refresh --check 'http://nginx.org/packages/sles/15' nginx-stable && \
zypper --non-interactive install -y nginx-"${NGINX_VERSION}" && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log && \
chown -R node:node /var/cache/nginx && \
touch /var/run/nginx.pid && \
chown node:node /var/run/nginx.pid && \
rm -rf "${GNUPGHOME}" \
/var/log/zypper.log && \
unset NGINX_KEY && \
zypper clean

COPY nginx.conf /etc/nginx/nginx.conf

USER 101
WORKDIR /home/node
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo insecure > /home/node/.curlrc && \
curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash && \
rm -rf install.sh \
nvm.sh \
.curlrc

USER 0
RUN rm -f /var/log/zypper.log && \
zypper --non-interactive remove -y shadow curl && \
zypper clean && \
zypper removerepo -a

RUN mkdir -p /usr/src/app
RUN chown node:node /usr/src/app

USER 101
ENV PATH $PATH:/home/node/.nvm/versions/node/v${NODE_VERSION}/bin

WORKDIR /usr/src/app

COPY package.json ./
RUN npm install

COPY . .

USER 0
RUN chown -R 101:101 /usr/src/app/.db
RUN chown -R 101:101 /usr/src/app/public/uploads

USER 101
ENV CHOKIDAR_USEPOLLING=true

EXPOSE 5050

CMD [ "/bin/bash", "/usr/src/app/dockerRun.sh" ]

ngix.conf

 events {
 }

 http {
 # default set of files and their content types
 include mime.types;
 # prompt user for download for any undeclared file format
 default_type application/octet-stream;
 # optimization when serving static files
  sendfile on;
  client_max_body_size 10M;
  upstream cms-backend {
    server 127.0.0.1:6060;
  }
  server {
    listen 5050 ssl;
    server_name localhost;
    ssl_certificate /etc/nginx/pki/cert.pem;
    ssl_certificate_key /etc/nginx/pki/key.pem;
    ssl_client_certificate /etc/nginx/pki/ca.pem;
    ssl_verify_client optional;

    location / {
    add_header X-Frame-Options "DENY";
    add_header Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; frame-ancestors 'none'; object-src 'none';";

    # remote ip and forwarding ip
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_hide_header X-Frame-Options;

    rewrite ^/(.*) /$1 break;
    proxy_pass http://cms-backend;
  }
 }
}

DockerRun.sh file

#!/bin/bash
/usr/sbin/nginx
npm run develop

I am using Windows machine. Actually I am new to docker and all. Can anybody help?

Nectar Mind
  • 145
  • 2
  • 17
  • Can you double-check that your script has Unix line endings and not DOS-style line endings? The extra carriage return characters can cause problems like what you're seeing. – David Maze Aug 07 '23 at 14:19
  • (I would typically recommend running your application and the Nginx proxy in two separate containers; you may be able to use the standard Docker Hub `node` and `nginx` images as bases. You could then put a single command in the image's `CMD` and avoid this script problem entirely.) – David Maze Aug 07 '23 at 14:20
  • @DavidMaze actually this was running before with same script on window. Someone was working on it and he left now. – Nectar Mind Aug 07 '23 at 14:30

0 Answers0