Prerequisites Before you proceed, make sure you have the following software installed on your machine:
Node.js and npm (Node Package Manager) - Download and Install Node.js Docker - Download and Install Docker Installation Follow these steps to set up the project:
Clone this repository to your local machine. Open a terminal or command prompt and navigate to the project folder. Local Development Step 1: Install Node Modules To install the project dependencies, run the following command:
bash
npm install Step 2: Start the Project To run the TypeScript project locally, use the following command:
npm run dev This command will use the ts-node package to execute TypeScript directly without the need to compile it manually.
Step 3: Testing If you have tests written for your project, you can run them using the following command:
npm test Ensure that your tests are correctly configured in your package.json file.
Docker Deployment Step 1: Dockerize the Project Create a Dockerfile in the root of your project. This file defines the Docker image for your application. Dockerfile
FROM node:latest
WORKDIR /app
RUN npm install --production
Copy the entire project to the container (you can add a .dockerignore file to exclude unnecessary files)
CMD ["npm", "start"] Step 2: Build and Run the Docker Container Open a terminal or command prompt in the project's root folder.
Build the Docker image using the following command:
docker build -t your-image-name . Once the image is built, you can run your application in a Docker container using:
docker run -d --name your-container-name -p 3000:3000 your-image-name The -d flag runs the container in detached mode (in the background). The -p flag maps the host's port (e.g., 3000) to the container's port (e.g., 3000) so you can access the application locally.
Using Docker Compose (Optional) If you prefer using Docker Compose for a more streamlined approach:
Create a docker-compose.yml file in the root of your project. Define the services and configurations as follows: yaml
version: "3" services: your-service-name: build: context: . dockerfile: Dockerfile ports: - "3000:3000" Run the following command to start your application using Docker Compose: bash
docker-compose up -d Contribution Feel free to contribute to this project by submitting bug reports, feature requests, or pull requests.