This project is a news aggregator web application built with React, TypeScript, and Vite. It fetches news articles from various sources using the NewsAPI and displays them in a user-friendly interface.
Follow these steps to build and run the project in a Docker container.
- Docker installed on your machine. Install Docker
- A NewsAPI API key. You can get one from NewsAPI.
Clone the project repository to your local machine:
git clone https://github.com/your-username/news-aggregator.git
cd news-aggregatorBuild the Docker image using the provided Dockerfile. Replace your_api_key_here with your actual NewsAPI key.
docker build --build-arg VITE_NEWS_API_KEY=your_api_key_here -t news-aggregator .--build-arg VITE_NEWS_API_KEY=your_api_key_here: Passes the API key as a build argument.-t news-aggregator: Tags the Docker image with the name news-aggregator.
Run the Docker container using the built image:
docker run -p 3000:3000 news-aggregator-
-p 3000:3000: Maps port 3000 on your local machine to port 3000 in the container. -
news-aggregator: The name of the Docker image to run.
Once the container is running, open your browser and navigate to:
http://localhost:3000You should see the news aggregator application running.
To stop the container, press Ctrl + C in the terminal where the container is running. Alternatively, you can stop it using Docker commands:
- Find the container ID:
docker ps- Stop the container:
docker stop <container_id>If you don’t have a NewsAPI key or want to use a test key, you can use the following test key:
VITE_NEWS_API_KEY=2cc3aa8f36e64abf9badb9594e55d815