/Express-App

Javascript Express app template, with a guide on using Docker to containerize your app and deploying it on Heroku.

Primary LanguageJavaScript

Express API Template

Clone this repository to your local machine to use Express...


Containerizing Express with Docker

  1. On vs code, hold command + shift + p to show command bar

  2. Search for Docker on pop-up tool bar and select:

 Docker: Add Docker Files to Workspace
  1. Select Node.js Application Platform

  2. Choose Package.json file

  3. Choose default port or input alternative:

 3000
  1. Select No on Include optional Docker Compose files?

  2. Dockerfile and .dockerignore files would be created (Edit as see fit)

  3. On terminal, enter below to build:

 docker build -t accountName/fileName .
  1. On terminal, enter below to run image as container:
 docker run -p 4000:3000 accountName/fileName>
  1. To rename image:
 docker image tag #imageId accountName/newFileName:latest

Extra:

To list all running connections on a port: sudo lsof -i :<PORT>

To kill all running connections on a port: sudo kill -9 <PID>

Deploying Express with Heroku

1. cd <dir>

2. git init

3. git add .

4. git commit -m "commit message"

5. curl https://cli-assets.heroku.com/install.sh | sh (Enter device password if present)

6. heroku login

7. heroku create

8. git push heroku master/main

9. heroku apps:rename newName (To rename app)