I'm running a cypress test in a Docker container with the DockerFile below and my code is throwing the error:
#12 0.662 /bin/sh: 1: $[npm,: not found
I searched previous post about similar error, but I couldn't find any answer to my problem. How can I fix the issue?
DockerFile:
FROM cypress/base:16.13.0
RUN mkdir /app
WORKDIR /app
COPY . /app
RUN npm install
RUN $(npm bin)/cypress verify
RUN $["npm", "run", "cypress:e2e"]
.dockerignore:
node_modules
You must install npm to use npm. so you could do this
RUN apt install sudo curl
RUN curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
then you can use npm after this
Related
docker can't find file develop.sh even though it's in the root directory
my Dockerfile:
FROM node:16.13.0
WORKDIR /app/medusa
COPY package.json .
COPY develop.sh .
COPY yarn.* .
RUN apt-get update
RUN apt-get install -y python
RUN npm install -g npm#latest
RUN npm install -g #medusajs/medusa-cli#latest
RUN npm install
COPY . .
ENTRYPOINT ["./develop.sh"]
Edit: I am trying to run an open source project called medusa, you can find the code here, I haven't changed any thing except node version in Dockerfile
as per #Charles Duffy suggestion: changing the entrypoint to ENTRYPOINT ["/bin/sh", "./develop.sh"] solved the issue
Here's my dockerfile:
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
COPY ./app /app/app
WORKDIR /app/app
RUN "pip install -r requirements.txt"
And here's my folder structure:
When I try to build the image using docker build -t myimage ., I get the following error:
Any insight into resolving this would be appreciated.
Try
RUN ["pip", "install", "-r", "requirements.txt"]
My api-server Dockerfile is following
FROM node:alpine
WORKDIR /src
COPY . .
RUN rm -rf /src/node_modules
RUN rm -rf /src/package-lock.json
RUN yarn install
CMD yarn start:dev
After docker-compose up -d
I tried
$ docker exec -it api-server sh
/src # curl 'http://localhost:3000/'
sh: curl: not found
Why is the command curl not found?
My host is Mac OS X.
node:alpine image doesn't come with curl. You need to add the installation instruction to your Dockerfile.
RUN apk --no-cache add curl
Full example from your Dockerfile would be:
FROM node:alpine
WORKDIR /src
COPY . .
RUN rm -rf /src/node_modules
RUN rm -rf /src/package-lock.json
RUN apk --no-cache add curl
RUN yarn install
CMD yarn start:dev
I am trying to build a Docker image for my API with the following Dockerfile:
FROM microsoft/dotnet AS build-env
ARG source
RUN echo "source: $source"
WORKDIR /app
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
RUN apt-get install nodejs
RUN node -v
RUN npm -v
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
#Copy everything else & build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "API_App.dll"]
However, when I run the docker build command, I keep getting the following error:
Unable to locate package nodejs
The command '/bin/sh -c apt-get install nodejs returned a non-zero code: 100
Can someone tell me why I am getting this error?
Node Version: 8.11.3
npm Version: 5.6.0
You may occasionally experience some cache issues when the live repositories you’re pulling data from have changed.
To fix this, modify the Dockerfile to do a cleanup and update of the sources before you install any new packages.
...
# clean and update sources
RUN apt-get clean && apt-get update
...
This answer is from digitalocean-issue
I have a dockerfile setup
FROM node:8.10.0
USER node
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node.npm-global
RUN npm install -g #angular/cli#1.6.8 ts-node#5.0.1
WORKDIR /opt/src
COPY . .
USER 0
RUN chown -R root /opt/src
RUN npm install
CMD ["npm", "run", "build:prod"]
this runs fine locally, but when I try to deploy it, seems like the chown command didn't work, as it errors on npm install and shows
Error: EACCES: permission denied, open '/opt/src/node_modules/nodent-runtime/dist/index.js'
what could be wrong?