Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rama41222/docker-template

Dockerizing a Nodejs app
https://github.com/rama41222/docker-template

docker docker-compose docker-compose-template docker-container docker-demo docker-image docker-machine docker-registry dockerfile dockerfile-templating javascript nodejs nodejs-server

Last synced: about 9 hours ago
JSON representation

Dockerizing a Nodejs app

Awesome Lists containing this project

README

        

Docker setup
------------
1. Create the .env
`mv .env.sample .env`
2. Add the environmental variables
3. Run
```
docker-compose up
docker-compose up -d #run in background
docker-compose down # remove
docker-compose stop # stop
docker-compose start # start stopped services
docker-compose run [service name] # run a single serivce in docker-compose manifest
docker-compose run web-cli # to ssh into the container
docker-compose build # Build the docker image
docker logs -f [container id] # to view logs
```

### Deployment

Change the docker CMD to following
`CMD ["npm", "run" ,"start"]`

### Build the image

**You have to manually add the user before running the image**

```
docker build . -t [repo-name]/[image-name]:[version]
docker run -it -p [host-port]:[container-port] [image-name] [cmd]
```
[Medium Article](https://itnext.io/lets-dockerize-a-nodejs-express-api-22700b4105e4)