This project is a basic setup for a web application using FastAPI and React, containerized with Docker. The backend serves a simple API that communicates with the frontend, which displays data retrieved from the API.
-
backend/
: Contains the FastAPI application.app/main.py
: Entry point for the FastAPI application.Dockerfile
: Docker configuration for building the backend image.requirements.txt
: Python dependencies required by the backend.
-
frontend/
: Contains the React application.public/index.html
: HTML template for the React application.src/
: React source files includingApp.js
andindex.js
.Dockerfile
: Docker configuration for building the frontend image.package.json
: NPM dependencies and scripts for the frontend.
-
.gitignore
: Specifies intentionally untracked files to ignore. -
docker-compose.yml
: Defines and runs multi-container Docker applications. -
LICENSE
: The license file. -
README.md
: Documentation about this project.
To run this project, you will need Docker and Docker Compose installed on your machine. Installation guides for Docker can be found here and for Docker Compose here.
-
Clone the Repository
git clone https://yourrepositoryurl/plain-fastapi-react-docker.git cd plain-fastapi-react-docker
-
Build and Run the Docker Containers
docker-compose up --build
This command builds the images for the frontend and backend if they don't exist and starts the containers. The backend is available at
http://localhost:80/
and the frontend athttp://localhost:3000/
. -
Viewing the Application
Open a browser and navigate to
http://localhost:3000/
to view the React application. It should display a message fetched from the FastAPI backend.
The backend server has the following API endpoint:
GET /
: Returns a simple JSON{ "Hello": "World" }
.
To stop the application and remove containers, networks, and volumes created by docker-compose up
, you can use:
docker-compose down -v
Contributions to this project are welcome. Please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE
file for details.