I'm trying to run a node.js app in a Docker container on Windows Server. I have limited control over the server. Most notably, the server doesn't have Hyper-V available, so (I believe) I need a Windows-based Docker image. I have a Dockerfile that I can successfully build locally, but I'm getting an error when I try to build everything in an Azure Pipeline:
Error: EPERM: operation not permitted, open 'C:\app\package-lock.json'
I have verified (with RUN dir) that the file is successfully copied.
Edit
The pipeline works, on Azure as well as locally, if I don't copy over package-lock.json
Also of note (maybe), there's another error at the very beginning of the pipeline output:
"C:\Program Files\Docker\docker.exe" pull "=installer c:\node\nodejs\ ."
invalid reference format
"C:\Program Files\Docker\docker.exe" inspect "=installer c:\node\nodejs\ ."
Error: No such object: =installer c:\node\nodejs\ .
Though that might not be related as it appears to commence with building the image.
Dockerfile
# escape=`
FROM mcr.microsoft.com/powershell:lts-nanoserver-1809 as installer
ARG NODE=16.3.0
RUN mkdir -p C:\node
WORKDIR C:\node
SHELL ["pwsh.exe", "-command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]
RUN Invoke-WebRequest -Uri https://nodejs.org/dist/v$env:NODE/node-v$env:NODE-win-x64.zip -OutFile nodejsZip.zip -UseBasicParsing `
&& Expand-Archive nodejsZip.zip -DestinationPath .`
&& Rename-Item node-v$env:NODE-win-x64 nodejs
FROM mcr.microsoft.com/windows/nanoserver:1809
WORKDIR C:\nodejs
COPY --from=installer C:\node\nodejs\ .
ENV PATH="$WindowsPATH;C:/nodejs"
RUN npm config set registry https://registry.npmjs.org/
ENV NODE_ENV=production
WORKDIR /app
# install and cache app dependencies
COPY package.json package-lock.json* npm-shrinkwrap.json* .npmrc .\
RUN dir
RUN npm install --production && move node_modules ..\
COPY . .
EXPOSE 8080
CMD ["npm", "start"]
Pipeline step
- task: Docker#2
displayName: Build and push Docker image
inputs:
command: buildAndPush
repository: ***
dockerfile: $(appDirectory)Dockerfile
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(Build.BuildId)
Pipeline output
Starting: Build and push Docker image
==============================================================================
Task : Docker
Description : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
Version : 2.187.0
Author : Microsoft Corporation
Help : https://aka.ms/azpipes-docker-tsg
==============================================================================
"C:\Program Files\Docker\docker.exe" pull "=installer c:\node\nodejs\ ."
invalid reference format
"C:\Program Files\Docker\docker.exe" inspect "=installer c:\node\nodejs\ ."
Error: No such object: =installer c:\node\nodejs\ .
[]
"C:\Program Files\Docker\docker.exe" build -f D:\a\1\s\App\Dockerfile [bunch of labels with revealing names] -t ***/[appName]:1610 -t ***/[appName]:latest -t ***/[appName]:1.1.0 D:\a\1\s\App
Sending build context to Docker daemon 156.5MB
Step 1/30 : FROM mcr.microsoft.com/powershell:lts-nanoserver-1809 as installer
lts-nanoserver-1809: Pulling from powershell
b9043d31610e: Already exists
9385842e37a1: Pulling fs layer
1785b1708bde: Pulling fs layer
8bbda5f0e88c: Pulling fs layer
69aef7d2d307: Pulling fs layer
ce716bfd5dfd: Pulling fs layer
01ded93fffb2: Pulling fs layer
54121c5fa6ac: Pulling fs layer
3f8033467b82: Pulling fs layer
9e9e60715d2d: Pulling fs layer
69aef7d2d307: Waiting
ce716bfd5dfd: Waiting
01ded93fffb2: Waiting
54121c5fa6ac: Waiting
3f8033467b82: Waiting
9e9e60715d2d: Waiting
8bbda5f0e88c: Verifying Checksum
8bbda5f0e88c: Download complete
1785b1708bde: Verifying Checksum
1785b1708bde: Download complete
9385842e37a1: Verifying Checksum
ce716bfd5dfd: Verifying Checksum
ce716bfd5dfd: Download complete
69aef7d2d307: Verifying Checksum
69aef7d2d307: Download complete
54121c5fa6ac: Verifying Checksum
54121c5fa6ac: Download complete
3f8033467b82: Verifying Checksum
3f8033467b82: Download complete
9385842e37a1: Pull complete
9e9e60715d2d: Verifying Checksum
9e9e60715d2d: Download complete
1785b1708bde: Pull complete
8bbda5f0e88c: Pull complete
69aef7d2d307: Pull complete
ce716bfd5dfd: Pull complete
01ded93fffb2: Verifying Checksum
01ded93fffb2: Download complete
01ded93fffb2: Pull complete
54121c5fa6ac: Pull complete
3f8033467b82: Pull complete
9e9e60715d2d: Pull complete
Digest: sha256:2742181d6096061fa10b0b0ef34a00a634e7361f4948f4d71d99df052a08da64
Status: Downloaded newer image for mcr.microsoft.com/powershell:lts-nanoserver-1809
---> 4375ea1bb0a3
Step 2/30 : ARG NODE=16.3.0
---> Running in a129a7c48527
Removing intermediate container a129a7c48527
---> 6b07c85950b7
Step 3/30 : RUN mkdir -p C:\node
---> Running in 09f84ee6dbc8
Removing intermediate container 09f84ee6dbc8
---> 3400da58010d
Step 4/30 : WORKDIR C:\node
---> Running in 3406bcfdbc3e
Removing intermediate container 3406bcfdbc3e
---> 1957d042581a
Step 5/30 : SHELL ["pwsh.exe", "-command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]
---> Running in cb32ef99f0ec
Removing intermediate container cb32ef99f0ec
---> a39d5e0ae00e
Step 6/30 : RUN Invoke-WebRequest -Uri https://nodejs.org/dist/v$env:NODE/node-v$env:NODE-win-x64.zip -OutFile nodejsZip.zip -UseBasicParsing && Expand-Archive nodejsZip.zip -DestinationPath . && Rename-Item node-v$env:NODE-win-x64 nodejs
---> Running in f693e5889205
Removing intermediate container f693e5889205
---> 88ac85fc56b9
Step 7/30 : FROM mcr.microsoft.com/windows/nanoserver:1809
---> ad675c9cb2d5
Step 8/30 : WORKDIR C:\nodejs
---> Running in 07e5c75044bb
Removing intermediate container 07e5c75044bb
---> 985de76e022c
Step 9/30 : COPY --from=installer C:\node\nodejs\ .
---> 614424adca70
Step 10/30 : ENV PATH="$WindowsPATH;C:/nodejs"
---> Running in 54c7d7063723
Removing intermediate container 54c7d7063723
---> 06f449a12162
Step 11/30 : RUN npm config set registry https://registry.npmjs.org/
---> Running in 88e0f906a572
npm notice
npm notice New minor version of npm available! 7.15.1 -> 7.16.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.16.0>
npm notice Run `npm install -g npm#7.16.0` to update!
npm notice
npm notice
npm notice New minor version of npm available! 7.15.1 -> 7.16.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.16.0>
npm notice Run `npm install -g npm#7.16.0` to update!
npm notice
Removing intermediate container 88e0f906a572
---> 37b0211fe99a
Step 12/30 : ENV NODE_ENV=production
---> Running in db15abf42b2e
Removing intermediate container db15abf42b2e
---> 1e1b5bfc11bf
Step 13/30 : WORKDIR /app
---> Running in db460e099de7
Removing intermediate container db460e099de7
---> 5bcaea65c911
Step 14/30 : COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", ".npmrc", ".\\"]
---> 6f1ebb928f0d
Step 15/30 : RUN dir
---> Running in 117829a3f0f5
Volume in drive C has no label.
Volume Serial Number is 1A2C-F251
Directory of C:\app
06/04/2021 04:44 PM <DIR> .
06/04/2021 04:44 PM <DIR> ..
06/04/2021 04:42 PM 2,645 .npmrc
06/04/2021 04:42 PM 1,720,232 package-lock.json
06/04/2021 04:42 PM 3,101 package.json
3 File(s) 1,725,978 bytes
2 Dir(s) 21,299,695,616 bytes free
Removing intermediate container 117829a3f0f5
---> b51123956a61
Step 16/30 : RUN npm install --production && move node_modules ..\
---> Running in 8e47b2ad349e
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\app\package-lock.json
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\app\package-lock.json'
npm ERR! [Error: EPERM: operation not permitted, open 'C:\app\package-lock.json'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\app\\package-lock.json'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ContainerUser\AppData\Local\npm-cache\_logs\2021-06-04T16_45_21_968Z-debug.log
The command 'cmd /S /C npm install --production && move node_modules ..\' returned a non-zero code: 4294963248
##[error]The process 'C:\Program Files\Docker\docker.exe' failed with exit code 4294963248
Finishing: Build and push Docker image
It turns out that the default user in mcr.microsoft.com/windows/nanoserver:1809 is ContainerUser, a non-administrator account. I'm not sure the exact permissions Docker's COPY command uses on Windows containers. On Linux it creates files owned by root though, so something similar in Windows. Switching to the ContainerAdministrator user (USER ContainerAdministrator) for the npm install process fixed my permissions problems.
Related
I am following a pluralsight tutorial- "Developing .NET Framework Apps with Docker" but dockerfile given in one of the demo failing for me.
Here is the dockerfile:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS builder
WORKDIR /src/PetShop.Api
COPY src/PetShop.Api/PetShop.Api.sln .
COPY src/PetShop.Api/PetShop.Api.Entities/PetShop.Api.Entities.csproj ./PetShop.Api.Entities/
COPY src/PetShop.Api/PetShop.Api.Model/PetShop.Api.Model.csproj ./PetShop.Api.Model/
COPY src/PetShop.Api/PetShop.Api.Products/PetShop.Api.Products.csproj ./PetShop.Api.Products/
COPY src/PetShop.Api/PetShop.Api.Products/packages.config ./PetShop.Api.Products/
RUN nuget restore PetShop.Api.sln -PackagesDirectory packages
COPY src /src
RUN msbuild PetShop.Api.Products/PetShop.Api.Products.csproj /p:Configuration=Release /p:OutputPath=c:/out
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
ENV APP_ROOT=C:\\inetpub\\wwwroot
COPY --from=builder /out/_PublishedWebsites/PetShop.Api.Products ${APP_ROOT}
COPY --from=builder /src/PetShop.Api/packages/Microsoft.Data.SqlClient.SNI.2.1.1/build/net46/Microsoft.Data.SqlClient.SNI.x64.dll ${APP_ROOT}/bin
COPY config/appsettings.json ${APP_ROOT}
COPY config/logging.json ${APP_ROOT}/config/
COPY config/connectionstrings.json ${APP_ROOT}/config/
And here is the output of the docker build command:
PS C:\Users\rg21580\Downloads\docker-dot-net-framework-apps-developing\02\demos\demo3> docker build -t petshop-api ./petshop-api
Sending build context to Docker daemon 94.21kB
Step 1/17 : FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS builder
4.8-windowsservercore-ltsc2019: Pulling from dotnet/framework/sdk
4612f6d0b889: Already exists
ba8181afd426: Pull complete
02ca74b83f10: Pull complete
5766b0ca35fc: Pull complete
ee971f2d3cad: Pull complete
8bd0de32312c: Pull complete
d1b79a53055d: Pull complete
b9073913d17e: Pull complete
6cc2f27ce166: Pull complete
835d2914821b: Pull complete
Digest: sha256:d91ffeee472a34f8d7ff717fef54422be2ad87e59478c2e507c59eed8aaaa02e
Status: Downloaded newer image for mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
---> dbbd921bf470
Step 2/17 : WORKDIR /src/PetShop.Api
---> Running in 53096698fe2b
Removing intermediate container 53096698fe2b
---> 0f9d67c78245
Step 3/17 : COPY src/PetShop.Api/PetShop.Api.sln .
---> a119a8190c29
Step 4/17 : COPY src/PetShop.Api/PetShop.Api.Entities/PetShop.Api.Entities.csproj ./PetShop.Api.Entities/
---> 0d25ee5d9c38
Step 5/17 : COPY src/PetShop.Api/PetShop.Api.Model/PetShop.Api.Model.csproj ./PetShop.Api.Model/
---> 35e667754785
Step 6/17 : COPY src/PetShop.Api/PetShop.Api.Products/PetShop.Api.Products.csproj ./PetShop.Api.Products/
---> 35bf8e689d58
Step 7/17 : COPY src/PetShop.Api/PetShop.Api.Products/packages.config ./PetShop.Api.Products/
---> 67128e1c97da
Step 8/17 : RUN nuget restore PetShop.Api.sln -PackagesDirectory packages
---> Running in c09cfa5df43b
MSBuild auto-detection: using msbuild version '17.1.0.7609' from 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin'.
Restoring NuGet package log4net.2.0.12.
Restoring NuGet package Antlr.3.5.0.2.
Unable to find version '3.5.0.2' of package 'Antlr'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org'
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nuget restore PetShop.Api.sln -PackagesDirectory packages' returned a non-zero code: 1
I am unable to resolve the error- "https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org' " which occurs at command- "RUN nuget restore PetShop.Api.sln -PackagesDirectory packages" of the docker file.Thank you so much in advance.
If you're sure there isn't a network issue (like a DNS issue), then try this solution:
https://sitecore.stackexchange.com/a/30015/1739
It helped me with the same problem.
I am seeing a Permission Denied error when trying to run a npx command in DockerFile.
The command is:
RUN $(npx cypress cache path)
Step 13/15 : RUN $(npx cypress cache path)
---> Running in 665c47c96bdb
/bin/sh: 1: /root/.cache/Cypress: Permission denied
Error response from daemon: The command '/bin/sh -c $(npx cypress cache path)' returned a non-zero code: 126
Failed to deploy '<unknown> Dockerfile: Dockerfile': Can't retrieve image ID from build stream
The full DockerFile is:
FROM cypress/base:10
RUN node --version
RUN npm --version
WORKDIR /home/node/app
COPY package.json package-lock.json ./
COPY app ./app
COPY serve.json ./
COPY cypress.json cypress ./
COPY cypress ./cypress
ENV CI=1
RUN npm ci
RUN $(npm bin)/cypress verify
RUN $(npx cypress cache path)
How can I sudo run this command, in order to obtain its output please?
Many thanks
i am working around docker and try to push a docker repository via GitHub & Travis-ci.
My push doesn't work and i don't find why. Can you help me to find my mistake ?
my repo : https://github.com/ty1l3r/Docker-Push-Travis-CI/tree/ebe9050a9c814dc2492364220b6e33daeabbad14
This is the travis job log
Worker information
0.15s0.00s0.01s0.00s0.01s
system_info
Build system information
0.02s0.01s0.63s0.24s0.05s0.00s0.04s0.00s0.01s0.01s0.01s0.01s0.01s0.00s0.00s0.02s0.00s0.01s0.34s0.00s0.00s0.00s0.01s0.00s0.10s0.01s0.81s0.00s0.09s6.03s0.00s2.71s0.00s2.45s
docker_mtu
resolvconf
services
3.02s$ sudo systemctl start docker
git.checkout
0.53s$ git clone --depth=50 --branch=main https://github.com/ty1l3r/Docker-Push-Travis-CI.git ty1l3r/Docker-Push-Travis-CI
0.01s
Setting environment variables from repository settings
$ export USERNAME_DOCKER=[secure]
$ export PASSWORD_DOCKER=[secure]
rvm
0.65s$ rvm use default
ruby.versions
$ ruby --version
No Gemfile found, skipping bundle install
51.98s$ docker build -t [secure]/node2 .
Sending build context to Docker daemon 116.7kB
Step 1/10 : FROM node
latest: Pulling from library/node
0400ac8f7460: Pulling fs layer
fa8559aa5ebb: Pulling fs layer
da32bfbbc3ba: Pulling fs layer
e1dc6725529d: Pulling fs layer
572866ab72a6: Pulling fs layer
63ee7d0b743d: Pulling fs layer
8c322550c0ed: Pulling fs layer
3a9ca1673e31: Pulling fs layer
64feb390fd3e: Pulling fs layer
e1dc6725529d: Waiting
572866ab72a6: Waiting
63ee7d0b743d: Waiting
8c322550c0ed: Waiting
3a9ca1673e31: Waiting
64feb390fd3e: Waiting
da32bfbbc3ba: Verifying Checksum
da32bfbbc3ba: Download complete
fa8559aa5ebb: Verifying Checksum
fa8559aa5ebb: Download complete
0400ac8f7460: Verifying Checksum
0400ac8f7460: Download complete
e1dc6725529d: Verifying Checksum
e1dc6725529d: Download complete
63ee7d0b743d: Verifying Checksum
63ee7d0b743d: Download complete
3a9ca1673e31: Verifying Checksum
3a9ca1673e31: Download complete
64feb390fd3e: Verifying Checksum
64feb390fd3e: Download complete
8c322550c0ed: Verifying Checksum
8c322550c0ed: Download complete
572866ab72a6: Verifying Checksum
572866ab72a6: Download complete
0400ac8f7460: Pull complete
fa8559aa5ebb: Pull complete
da32bfbbc3ba: Pull complete
e1dc6725529d: Pull complete
572866ab72a6: Pull complete
63ee7d0b743d: Pull complete
8c322550c0ed: Pull complete
3a9ca1673e31: Pull complete
64feb390fd3e: Pull complete
Digest: sha256:bf60a164bc588967ce6e3342c9d6508bf9ad2e7e2a1c237315596eab3e13428b
Status: Downloaded newer image for node:latest
---> ca36fba5ad66
Step 2/10 : RUN mkdir /usr/src/app
---> Running in ead7eee85d04
Removing intermediate container ead7eee85d04
---> db5142aef70d
Step 3/10 : WORKDIR /usr/src/app
---> Running in ae004d76578e
Removing intermediate container ae004d76578e
---> f99a31e3bd7f
Step 4/10 : ENV PATH /usr/src/app/node_modules/.bin:$PATH
---> Running in fc0ecc340d36
Removing intermediate container fc0ecc340d36
---> 6bb3caae8781
Step 5/10 : COPY package*.json /usr/src/app
---> 8b0315d294b6
Step 6/10 : RUN npm install
---> Running in 5b946ac6267a
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated chokidar#1.7.0: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
added 495 packages, and audited 495 packages in 16s
14 packages are looking for funding
run `npm fund` for details
5 low severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
npm notice
npm notice New patch version of npm available! 7.0.3 -> 7.0.6
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.6>
npm notice Run `npm install -g npm#7.0.6` to update!
npm notice
Removing intermediate container 5b946ac6267a
---> 4d6532f814f7
Step 7/10 : RUN npm update
---> Running in e8ad49b808f6
up to date, audited 495 packages in 7s
14 packages are looking for funding
run `npm fund` for details
5 low severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Removing intermediate container e8ad49b808f6
---> ff33fe82d1a4
Step 8/10 : COPY . /usr/src/app
---> 54d8de7e3027
Step 9/10 : EXPOSE 4000
---> Running in 60819e76c49d
Removing intermediate container 60819e76c49d
---> 7f28f29c75e4
Step 10/10 : CMD [ "npm", "start"]
---> Running in 0043ac3e416e
Removing intermediate container 0043ac3e416e
---> 0f99dd5d05d1
Successfully built 0f99dd5d05d1
Successfully tagged [secure]/node2:latest
The command "docker build -t [secure]/node2 ." exited with 0.
0.07s$ docker images [secure]/nodes2
REPOSITORY TAG IMAGE ID CREATED SIZE
The command "docker images [secure]/nodes2" exited with 0.
before_deploy
0.51s$ docker login -u="$USERNAME_DOCKER" -p="$PASSWORD_DOCKER"
dpl_0
1.37s$ rvm $(travis_internal_ruby) --fuzzy do ruby -S gem install dpl
dpl.1
Installing deploy dependencies
dpl.2
Preparing deploy
dpl.3
Deploying application
failed to deploy
This is my travis.yml
sudo: required
services:
- docker
script:
- docker build -t tyl13r/node2 .
- docker images tyl13r/nodes2
before_deploy:
- docker login -u="$USERNAME_DOCKER" -p="$PASSWORD_DOCKER"
deploy:
skip_cleanup: true
provider: script
script: docker push tyl13r/DockerTravisCi
on:
branch: main
my Dockerfile
FROM node
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package*.json /usr/src/app
RUN npm install
RUN npm update
COPY . /usr/src/app
EXPOSE 4000
CMD [ "npm", "start"]
I am trying to create and run a Docker image of my Angular application. It works perfectly fine locally however I am having problems when it is coming to the docker run command.
My Dockerfile is:
FROM node:current
#FROM node:current-slim
#FROM node:12.13.1-alpine
WORKDIR /usr/src/app
COPY package.json .
COPY proxy.conf.json .
RUN npm install
EXPOSE 4200
CMD [ "npm", "run", "dev" ]
In my package.json the scripts are:
"dev": "concurrently \"npm start\" \"ng serve --proxy-config proxy.conf.json\""
and the two Docker commands I am running are:
docker build --tag fuel-consumption-front:0.0.0 .
docker run --publish 8000:4200 --detach --name fuel fuel-consumption-front:0.0.0
The Docker logs are saying (or this is the output on my desktop Docker application for this):
> fuel-consumption-front#0.0.0 dev /usr/src/app
> concurrently "npm start" "ng serve --proxy-config proxy.conf.json"
sh: 1: concurrently: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! fuel-consumption-front#0.0.0 dev: `concurrently "npm start" "ng serve --proxy-config proxy.conf.json"`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fuel-consumption-front#0.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-03-25T15_30_19_063Z-debug.log
It is the first line that is making me think this is something to do with concurrently not being able to be run
I have tried different node images (commented out in the Dockerfile) and also npm insall -g within the Dockerfile. There is not an entry for concurrentrly in the package.json file either. All different methods are throwing up the same error
I am pretty new with Docker and was using the example from the Docker pages as a template. Their example worked perfectly fine when doing this.
I had more of a play with this after leaving it for a while. Turned out I didn't save my Dockerfile when I added npm install concurrently. Now the Dockerfile reads (with a few more tweaks):
FROM node:current-slim
WORKDIR /usr/src/app
COPY package.json .
COPY proxy.conf.json .
RUN npm install
RUN npm install concurrently
COPY . .
EXPOSE 4200
CMD [ "npm", "run", "dev" ]
Now onto the next issue....need to make the image smaller and it says it compiles fine in the logs but can't connect on localhost:8000 (another problem for another day!)
I keep getting a Could not find a required file for my docker build and I am not sure why. I am new to docker so is there a way I can "step through" the build process? I am running
docker build .
when I am INSIDE the /redribbon-client directory
output:
$ docker build .
Sending build context to Docker daemon 315.9MB
Step 1/6 : FROM node:alpine as builder
---> 4acd7c5129dc
Step 2/6 : WORKDIR "/client"
---> Using cache
---> c57cd917bb87
Step 3/6 : COPY ./package.json .
---> Using cache
---> 4098880ac4a5
Step 4/6 : RUN npm install
---> Using cache
---> 1015d2aec06c
Step 5/6 : COPY ./src/ .
---> Using cache
---> 5c895812a8c8
Step 6/6 : RUN npm run start
---> Running in 63ff064c6e84
> redribbon-client#0.1.0 start /client
> react-scripts start
Could not find a required file.
Name: index.html
Searched in: /client/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! redribbon-client#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the redribbon-client#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-02-04T03_06_26_933Z-debug.log
project structure:
/redribbon-client
Dockerfile
/src
/public
package.json
Dockerfile
FROM node:alpine as builder
WORKDIR "/client"
COPY ./package.json .
RUN npm install
COPY ./src/ .
RUN npm run start
You will need to copy the public folder over as well. The error stated that it was trying to look for public folder
Could not find a required file.
Name: index.html
Searched in: /client/public
Can you try again with the new Dockerfile?
FROM node:alpine as builder
WORKDIR "/client"
COPY ./package.json .
RUN npm install
COPY ./src/ .
COPY ./public/ .
RUN npm run start
Alternatively, you can copy everything over like this: COPY . .