Coder Social home page Coder Social logo

npm-run's Introduction

Docker Image for Running NodeJS Applications

This Docker image provides an easy way to run your NodeJS applications in a container. It comes pre-installed with all the required software, libraries and tools, including Ubuntu, NodeJS, tini, and npm. The exposed ports are 3000, 4200, 80 and 443, and the offered volume is /apt.

  • tag 2.0 - based on node:19.6.0-buster-slim and ported to ubuntu:jammy-20230126
  • tag 1.0 - based on node:9-stretch

Key Features

  • Pre-installed software, libraries and tools:
    • Ubuntu image
    • NodeJS
    • tini
    • npm
  • Exposed ports:
    • 3000
    • 4200
    • 80
    • 443
  • Volumes offered in the image:
    • /apt

Getting started

  1. Pull the image from Docker Hub using the following command:
docker image pull asaramet/npm-run
  1. Start the container, mapping exposed ports to your desired local ports (e.g. 80), and mount your local folder to the container using the -v option.

For example, to mount the current working directory:

docker container run --rm -p 80:80 -v $(pwd):/app asaramet/npm-run

Or, to mount the local folder /path/to/local/folder to the container's /app directory:

docker container run --rm -p 4200:4200 -p 80:80 -p 443:443 -v /path/to/local/folder:/app asaramet/npm-run
  1. Enter a running container using the following commands:
# Get the container ID
docker container ls -a

# Start the container interactively
docker container exec -it <CONTAINER_ID> bash 

# Run other commands from your 'package.json', for example 'compile' command: 
npm run compile
  1. The container will automatically run npm install and npm start upon launch. You can add this command to your docker-compose.yml file for easy configuration. Here is an example:
node_server:
  image: asaramet/npm-run
  ports:
    - "3000:3000"
    - "443:443"
    - "80:80"
  volumes:
    - ./node-server:/app
  command: npm install && npm cache clean --force && npm start

npm-run's People

Contributors

asaramet avatar

Watchers

 avatar

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.