Express API Template
Clone this repository to your local machine to use Express...
Containerizing Express with Docker
-
On vs code, hold
command + shift + p
to show command bar -
Search for Docker on pop-up tool bar and select:
Docker: Add Docker Files to Workspace
-
Select
Node.js
Application Platform -
Choose
Package.json
file -
Choose default port or input alternative:
3000
-
Select
No
on Include optional Docker Compose files? -
Dockerfile
and.dockerignore
files would be created (Edit as see fit) -
On terminal, enter below to build:
docker build -t accountName/fileName .
- On terminal, enter below to run image as container:
docker run -p 4000:3000 accountName/fileName>
- 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)