GithubHelp home page GithubHelp logo

sample-node-app's Introduction

Sample Node.js App for Docker Deployment Testing

This repository contains a simple Node.js application named app.js and a Dockerfile to facilitate easy Docker deployments on different environments.

Purpose

The main goal of this application is to serve as a testing ground for Docker deployments on various environments. It provides a basic Node.js web server using the Express framework to showcase how a Node.js application can be containerized with Docker.

Prerequisites

Before running the Dockerized application, you need to have Docker installed on your system.

Running the App with Docker

Follow these steps to run the sample Node.js app using Docker:

  1. Clone this repository to your local machine:

    git clone https://github.com/your-username/sample-node-app.git
    cd sample-node-app
  2. Build the Docker image using the provided Dockerfile:

    docker build -t sample-node-app .
  3. Run the Docker container from the built image:

    docker run -d -p 8080:8080 --name sample-node-app-container sample-node-app

    The application will start within the Docker container, and it will be accessible at http://localhost:8080/.

Routes

The application defines the following routes:

curl examples to run the endpoints of the sample Node.js app locally:

  1. GET /:

    This endpoint returns a simple message indicating that the Node Sample App is up and running.

    curl http://localhost:8080/

    Output:

    Hello World!!! Node Sample App is up and running!
    
  2. GET /ping:

    This endpoint returns "Pong!" as the response.

    curl http://localhost:8080/ping

    Output:

    Pong!
    
  3. POST /ping:

    This endpoint returns "POST: Pong!" as the response.

    curl -X POST http://localhost:8080/ping

    Output:

    POST: Pong!
    

Dockerfile

The repository includes a Dockerfile that sets up the Node.js environment, installs the app dependencies, and exposes port 8080 for communication with the outside world. The final image is based on the official Node.js Alpine image to keep it lightweight.

FROM node:alpine

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json .
RUN npm install

# Bundle app source
COPY . .

EXPOSE 8080

CMD [ "npm", "start" ]

License

This project is licensed under the MIT License.

Feel free to use this sample Node.js application and the provided Dockerfile as a starting point for your Docker deployments on different environments. Happy testing and coding!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.