This demo app shows a simple user profile app set up using
- index.html with pure js and css styles
- nodejs backend with express
- mongodb for data storage
- mongoexpress for a db ui
docker build -t myapp:v1.0 .
docker network create mongo-network
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --name mongodb --net mongo-network mongo
docker run -d -p 8080:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password --net mongo-network --name mongo-express -e ME_CONFIG_MONGODB_SERVER=mongodb mongo-express
- url:
http://localhost:8080 - db:
my-db - collection:
users
cd appnpm installnode server.js
http://localhost:3000
docker-composereads env vars from.envfile.- The
.envcan be overidden by host env vars. - fill required values on
.envor add them withexport - If runnning on remote host (e.g. ec2 e.t.c):
- add the host-ip in
app/public/javascripts/script.jsand rebuild/push image - open ports 3000 and 8080 on the host.
- install docker on host
- scp docker-compose.yaml on host
- docker login if image is on private repos
- add the host-ip in
docker compose -f docker-compose.yaml up -d OR
docker compose up -d
- create a new database "my-db"
- create a new collection "users" in the database "my-db"
Based on: techworld-js-docker-demo-app