Code Monkey home page Code Monkey logo

node-docker-example's Introduction

Running Node.js apps with docker - example code

This repository is used as support of my video(https://www.youtube.com/watch?v=7rqavBlLFbg) about how to run node.js applications using docker. It includes examples of linked services, envioronment variables, node_modules optiomization and integration with npm 5 using package-lock to optimize dependency installation on image building.

Example APP

The example Node.js app includes dummy code and tests

Running the application

The application is built with Node.js and already has all environment configured with docker. To start the application you will need docker and docker-compose installed on the machine. Having that you may run:

docker-compose up

And then the application and database will be started:

Starting nodedocker_mongodb_1 ...
Starting nodedocker_mongodb_1 ... done
Starting nodedocker_app_1 ...
Starting nodedocker_app_1 ... done

The application will be avaible on PORT 3000 by default, but it's configurable via docker-compose.yml file as an environment variable.

Running the application in development mode

Sometimes you would like to run the application in development mode. This project already has a prepared enviroment for that, you have to run:

docker-compose -f docker-compose.development.yml up

This docker compose file will start the application using nodemon and will share the local application code with the container. Any change on the hosts code will restart the application (whitout restarting the container because nodemon is taking care of that).

Running the tests

To run the tests using docker you just have to run the following command:

docker-compose -f docker-compose.test.yml up

And then all tests will be ran and the status exit code will be 0 or 1 that means true or false.

node-docker-example's People

Contributors

waldemarnt avatar dependabot[bot] avatar dopraxcom 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.