Skip to content

techtitan1998/express-backend

Repository files navigation

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:

start project in development

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

Use the official Node.js image as a base image

FROM node:latest

Set the working directory inside the container

WORKDIR /app

Copy package.json and package-lock.json to the container

Install project dependencies

RUN npm install --production

Copy the entire project to the container (you can add a .dockerignore file to exclude unnecessary files)

Set the command to run Node.js application

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published