This project is a React Golang Todo project built with React (Vite + Typescript + SWC), a framework designed for efficient and scalable UI applications. It also employs Docker for containerization, NVM for managing Node.js versions.
- Node.js version 20.x.x (LTS)
- Docker (Optional)
- NVM (optional, for managing Node.js versions)
Before starting, ensure you have Node.js installed. It's recommended to use NVM to manage Node.js versions. The project uses the Node.js version specified in .nvmrc
.
-
Clone this repository:
git clone https://github.com/pashamakhilkumarreddy/golang-react-todo.git
-
Navigate to the project directory:
cd golang-react-todo
-
If using NVM, set the correct Node.js version:
nvm use
-
Create a
.env
file in the project root directory and add the required environment variables (use.env.example
as a reference).cp .env.example .env
-
Install dependencies:
npm install
To start the application:
-
Development Mode:
npm run dev
-
Production Mode:
npm run build
The project includes Docker Compose files for various environments. Ensure the necessary environment variables are set in the corresponding .env
files (use .env.example
as a reference).
To build and run the Dockerfile you provided, you'll need to follow these steps. The Dockerfile describes a multi-stage build process where the first stage is for building a Node.js application and the second stage is for serving the built application using Nginx. Here’s how you can do it:
-
Build the Docker Image
Open a terminal, navigate to the directory where your Dockerfile is located, and run the following command to build the Docker image. Replace
golang-react-todo
with your desired image name if different:docker build -t golang-react-todo .
The
-t
flag tags the image with a name (golang-react-todo
in this case). The.
specifies the build context, which is the current directory. -
Run the Docker Container
Once the image is built, you can run a container from it using the following command:
docker run -d -p 80:80 --name react-app golang-react-todo
-
Access Your Application
After running the container, you can access your application in a web browser by navigating to
http://localhost
. If you mapped a different port, adjust the URL accordingly. -
Check Logs (Optional)
If you need to check the logs to see if everything is running smoothly, you can use:
docker logs my-react-app
-
Stop and Remove the Container (Optional)
To stop the container, use:
docker stop my-react-app
To remove the container, use:
docker rm my-react-app
-
Run Tests:
npm test
-
Run ESLint:
npm run lint
-
Format Code:
npm run format:fix
Pre-commit hooks using Husky and lint-staged enforce linting and formatting. To bypass these hooks temporarily:
git commit --no-verify -m "Your commit message"
Key npm scripts include:
npm run build
: Build the application for production.npm run format
: Format code using Prettier.npm run lint
: Lint code using ESLint.npm run start
: Start the application in production mode.npm run start:dev
: Start the application in development mode.npm run start:debug
: Start the application in debug mode.
Refer to the package.json
file for more details.
For contributing guidelines, see the Contributing guide.