Reputation: 33
While starting a react app on azure Linux container following error is thrown. The image runs successfully on docker container in local machine.
[34mℹ[39m [90m「wds」[39m: Project is running at http://192.168.0.13/ [34mℹ[39m [90m「wds」[39m: webpack output is served from [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /react-assignment1/public [34mℹ[39m [90m「wds」[39m: 404s will fallback to / Starting the development server...
node:events:491 throw er; // Unhandled 'error' event ^
Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT at ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Emitted 'error' event on ChildProcess instance at: at ChildProcess._handle.onexit (node:internal/child_process:289:12) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', spawnargs: [ '-NoProfile', '-NonInteractive', '–ExecutionPolicy', 'Bypass', '-EncodedCommand', 'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAwADAAMAAiAA==' ] }
Node.js v18.14.1
Upvotes: 1
Views: 481
Reputation: 1073
I have tried reproducing the same using the steps below and got positive results.
Step 1: Create react app using the below command.
#npx create-react-app <app-name>
Refer to this link Create a New React App – React (reactjs.org) for more information on creating react app.
Step 2: Write Dockerfile and place it in the root folder of the react application.
FROM node:18-alpine3.16
WORKDIR /app
COPY . /app
RUN npm install
RUN npm run build
CMD ["npx", "serve", "-s", "build"]
Step 3: Build the Dockerfile with the below command and verify the docker image.
$docker build -t <image_name> <location of the docker file> (“.” Indicates current working directory)
`$docker image`s --> to check for images
Step 4: Run the image locally using the below command and access it on the browser.
$docker run -d -p <host port>:<container port> <image name>
Step 5: Tag the docker image with the ACR login server name and push it to ACR.
$docker tag reactappaci10:latest humbleacr.azurecr.io/reactappaci10:latest
$docker images
$docker push humbleacr.azurecr.io/reactappaci10
Step 6: Create Azure Container Instance with the below configuration.
Note: ACI port and container port must be the same.
Now access the [ip address:port] in the browser.
Upvotes: 0