cogentapps / chat-with-gpt

An open-source ChatGPT app with a voice
https://www.chatwithgpt.ai
MIT License
2.29k stars 485 forks source link

How can I run backend and frontend separately? #176

Open MirzaHasnat opened 10 months ago

MirzaHasnat commented 10 months ago

I'm encountering difficulties while attempting to run the backend and frontend parts of chat-with-gpt application separately using Docker. I'm seeking assistance to properly configure my Docker setup so that I can run both the backend and frontend components independently.

Steps Taken:

I've created separate Dockerfiles for the backend and frontend components. I've built Docker images for both the backend and frontend using "docker build" commands. I've tried to run the containers using "docker run" commands, specifying the appropriate ports. Issues Faced:

When trying to run the frontend container, it gets stuck during the build process or shows unexpected behavior. Running the backend container separately leads to errors related to dependencies or configurations. I'm unsure about how to handle environment variables, data sharing, and networking between the backend and frontend containers.

Expected Outcome:

I'm looking for guidance and best practices on how to properly structure my Docker setup to achieve the following: Run the backend and frontend parts of chat-with-gpt as separate Docker containers.

Request for Assistance:

I would greatly appreciate any assistance, suggestions, or examples from the community on how to structure my Docker setup to achieve the above objectives. If anyone has successfully Dockerized a similar project with separate backend and frontend components, I'd love to hear about your experiences and best practices.

Please share your insights, tips, or examples on how to set up the Docker environment for running backend and frontend components separately.

Thanks

lucasfariaslf commented 10 months ago

@MirzaHasnat Any reason why you did not go for Docker Compose instead of managing different containers yourself? Setting up back- and front-end environments is one of its most common applications.

MirzaHasnat commented 10 months ago

@MirzaHasnat Any reason why you did not go for Docker Compose instead of managing different containers yourself? Setting up back- and front-end environments is one of its most common applications.

I'm added new features in this source code and trying to add more features but I'm having trouble while running the application in production.

What I'm experiencing? The application works fine with the ip address url and new features works as well.

But we run the same application on a domain like: chatgpt.com (example) then the application does not work properly its send 2 or 3 requests without any error and then the response comes with html page of 404(page not be found) but the request status 200.

After debugging further I found out that the request is reaching the server and executing successfully and sending the response to the client properly. But somehow in between of sending request the 404 html page is received to the client.

So I thought this issue is something related to domain. That's why I thought I should run backend and frontend separately and test it if it's work or not.

Thanks

lucasfariaslf commented 10 months ago

You'd have to paste the errors you're getting for we to be able to help. Independently of that tho, I think you should try setting up your approach using Docker Compose. As I see now you are using two different Dockerfiles and trying to establish a network for them, that's not how you do it usually. Docker Compose will make that much, much easier. Quick google and found this nice example.

MirzaHasnat commented 10 months ago

You'd have to paste the errors you're getting for we to be able to help. Independently of that tho, I think you should try setting up your approach using Docker Compose. As I see now you are using two different Dockerfiles and trying to establish a network for them, that's not how you do it usually. Docker Compose will make that much, much easier. Quick google and found this nice example.

Let me check that.

Thanks