Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ENOENT: no such file or directory, stat '/client/dist/index.html' #146

Closed
bing2008 opened this issue Apr 2, 2023 · 13 comments
Closed

Comments

@bing2008
Copy link

bing2008 commented Apr 2, 2023

Hello sir,

When i pull new version and run with docker cmd "docker-compose up", and browse the url,
it says "Not Found" in the page, and the console shows:
"chatgpt-clone-api-1 | Error: ENOENT: no such file or directory, stat '/client/dist/index.html'"

Any advice about it?

@danny-avila
Copy link
Owner

danny-avila commented Apr 2, 2023

Hello sir,

When i pull new version and run with docker cmd "docker-compose up", and browse the url, it says "Not Found" in the page, and the console shows: "chatgpt-clone-api-1 | Error: ENOENT: no such file or directory, stat '/client/dist/index.html'"

Any advice about it?

did you pull the latest update from main? This was an issue and it was fixed.

@danny-avila
Copy link
Owner

Just ran docker-compose up with latest update to main and no issue

@bing2008
Copy link
Author

bing2008 commented Apr 3, 2023

Hi danny,
After i delete the old folder and clone the new code (version:3b8c4efcf1ba55b5d833a0560e61de832154edb2)
the issue are still there: after i create a .env file in /api flolder and config it, and go to parent folder and use "docker-compose up" command, it still shows "chatgpt-clone-api-1 | Error: ENOENT: no such file or directory, stat '/client/dist/index.html'".

I have give it the folder enough privilege by the way.

@danny-avila
Copy link
Owner

Can you copy paste your dockerfile in the root folder here?

@bing2008
Copy link
Author

bing2008 commented Apr 3, 2023

FROM node:19-alpine AS react-client
WORKDIR /client
# copy package.json into the container at /client
COPY /client/package*.json /client/
# install dependencies
RUN npm ci
# Copy the current directory contents into the container at /client
COPY /client/ /client/
# Build webpack artifacts
RUN npm run build

FROM node:19-alpine AS node-api
WORKDIR /api
# copy package.json into the container at /api
COPY /api/package*.json /api/
# install dependencies
RUN npm ci
# Copy the current directory contents into the container at /api
COPY /api/ /api/
# Copy the client side code
COPY --from=react-client /client/dist /client/dist
# Make port 3080 available to the world outside this container
EXPOSE 3080
# Expose the server to 0.0.0.0
ENV HOST=0.0.0.0
# Run the app when the container launches
CMD ["npm", "start"]

# Optional: for client with nginx routing
FROM nginx:stable-alpine AS nginx-client
WORKDIR /usr/share/nginx/html
COPY --from=react-client /client/public /usr/share/nginx/html
# Add your nginx.conf
COPY /client/nginx.conf /etc/nginx/conf.d/default.conf
ENTRYPOINT ["nginx", "-g", "daemon off;"]

@danny-avila danny-avila reopened this Apr 3, 2023
@danny-avila
Copy link
Owner

I think I may know the issue before trying a fix.

@danny-avila
Copy link
Owner

can you make sure to delete the docker container you already had, and then delete the node-api image? Not sure if you are using docker desktop, but using that GUI will make it easier.

After doing that, goto the docker container and inspect the api-1 files. let me know what is in the client folder

image

image

@bing2008
Copy link
Author

bing2008 commented Apr 3, 2023

I am using a debain operating system, and i had try to use "docker-compose down" and "docker-compose rm" command delete the container, before using "docker-compose up" comand to create and start the container.

@danny-avila
Copy link
Owner

maybe it has the images cached because the only thing that makes sense to me is to delete the image as well before doing compose up after an update to the project

@bing2008
Copy link
Author

bing2008 commented Apr 3, 2023

Here is the folder of clients:

/api # ls app/clients
bingai.js           chatgpt-browser.js  chatgpt-client.js   chatgpt-custom.js   sydney.js

But i think i found the reason of this issue: Nodejs build failure in my system.
When i use "docker-compose up --build" to force build the code, it say FATAL ERROR.

#0 34.85 <--- JS stacktrace --->
#0 34.85
#0 34.86 FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
#0 36.24 npm ERR! path /client
#0 36.24 npm ERR! command failed
#0 36.24 npm ERR! signal SIGABRT
#0 36.24 npm ERR! command sh -c vite build
#0 36.25
#0 36.25 npm ERR! A complete log of this run can be found in:
#0 36.25 npm ERR!     /root/.npm/_logs/2023-04-03T16_01_06_729Z-debug-0.log
------
failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

So maybe my server's memory is too low, it's only has 1G memory.
I will try to enlarge the memory and try again.

@danny-avila
Copy link
Owner

Oh I meant .client/ not .api/clients but yes looks like it definitely is the build error

@bing2008
Copy link
Author

bing2008 commented Apr 3, 2023

Oh, the .client/ folder like this, has no dist folder in it. so same conclusion~

/ # ls client
node_modules  public

@danny-avila
Copy link
Owner

Let me know if you got this working with more memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants