-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f8fbed
commit 986ee80
Showing
3 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Start with a Node.js base image for building the frontend | ||
FROM node:20 AS frontend-build | ||
|
||
# Set working directory for frontend | ||
WORKDIR /app/frontend | ||
|
||
# Copy frontend files | ||
COPY frontend/package*.json ./ | ||
|
||
# Install frontend dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the frontend code | ||
COPY frontend/ ./ | ||
|
||
# Build the frontend | ||
RUN npm run build | ||
|
||
# Start a new stage with a Python base image for the backend | ||
FROM python:3.10 | ||
|
||
# Set working directory for backend | ||
WORKDIR /app | ||
|
||
# Copy backend requirements and install dependencies | ||
COPY backend/requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy the backend code | ||
COPY backend/ . | ||
|
||
# Copy the built frontend files to the backend's static directory | ||
COPY --from=frontend-build /app/frontend/build /app/frontend | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8000 | ||
|
||
# Command to run the application | ||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Hackathon CodeFusion | ||
|
||
This project combines a FastAPI backend with a React frontend, containerized using Docker. | ||
|
||
## Building and Running with Docker | ||
|
||
### Production Build | ||
|
||
To build and run the production version of the application: | ||
|
||
1. Ensure you have Docker installed on your system. | ||
|
||
2. Clone this repository and navigate to the project root directory. | ||
|
||
3. Build the Docker image: | ||
``` | ||
docker build -t fastapi-react-app . | ||
``` | ||
|
||
4. Run the container: | ||
``` | ||
docker run -p 8000:8000 fastapi-react-app | ||
``` | ||
|
||
5. Access the application at `http://localhost:8000` | ||
|
||
|
||
## Project Structure | ||
|
||
- `backend/`: Contains the FastAPI application | ||
- `frontend/`: Contains the React application | ||
- `Dockerfile`: Defines the production Docker image | ||
|
||
## API Documentation | ||
|
||
When running the application, you can access the API documentation at: | ||
|
||
- Swagger UI: `http://localhost:8000/api/docs` | ||
- OpenAPI JSON: `http://localhost:8000/api/openapi.json` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters