This repository contains a Next.js application configured for both development and production environments. Follow the instructions below to set up and run the application either locally or using Docker.
Before you begin, ensure you have the following installed on your system:
- Node.js (v18.x)
- npm (comes with Node.js)
- Docker (for running the application in a container)
To run the application locally, follow these steps:
Clone the repository and install the dependencies:
git clone https://github.com/joshuakaluba/hackernews.git
cd hackernews
npm install
To start the application in development mode with hot reloading enabled:
npm run dev
This will start the Next.js server on http://localhost:3000
. Open your browser and navigate to this address to view the application.
To build and run the application in production mode:
npm run build
npm start
The project includes a Dockerfile for building a containerized version of the application and a docker-compose.yml for easy orchestration.
To build the Docker image, run the following command in the project root:
docker-compose build
To start the application using Docker Compose:
docker-compose up
This will start the application in development mode by default. The application will be available on http://localhost:3000
.
If you want to run the Docker container in production mode, you can modify the command
in docker-compose.yml
to use npm start
instead of npm run dev
. Alternatively, you can build and run the Docker image directly:
docker build -t nextjs-app .
docker run -p 3000:3000 nextjs-app
For more details on working with Next.js, refer to the official Next.js documentation