Dockerized Node.js Contact Form backend with MongoDB storage
150
A Node.js-based contact form web application, containerized for easy deployment. Uses MongoDB for data storage.
To quickly start the application and its dependencies using Docker, run the following commands in separate terminals or as background processes:
# Start MongoDB
docker run -d \
--name mongodb \
-e MONGO_INITDB_ROOT_USERNAME=<username> \
-e MONGO_INITDB_ROOT_PASSWORD=<password> \
-e MONGO_INITDB_DATABASE=<database> \
-p 27017:27017 \
mongo:4.4
# Start Mongo Express
docker run -d \
--name mongo-express \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=<username> \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=<password> \
-e ME_CONFIG_MONGODB_URL=mongodb://<username>:<password>@mongodb:27017/<database>?authSource=admin \
--link mongodb \
-p 8081:8081 \
mongo-express
# Start the Contact Form Web Application
docker run -d \
--name contact-form \
-p 3000:3000 \
-e MONGO_URL=mongodb://<username>:<password>@mongodb:27017/<database>?authSource=admin \
--link mongodb \
prancodes/contact-form:latest
docker-compose.yaml file in your project directory with the following content:services:
web:
image: prancodes/contact-form:latest
ports:
- 3000:3000
environment:
MONGO_URL: mongodb://<username>:<password>@mongodb:27017/<database>?authSource=admin
depends_on:
- mongodb
- mongo-express
mongodb:
image: mongo:4.4
environment:
MONGO_INITDB_ROOT_USERNAME: <username>
MONGO_INITDB_ROOT_PASSWORD: <password>
MONGO_INITDB_DATABASE: <database>
ports:
- 27017:27017
mongo-express:
image: mongo-express
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: <username>
ME_CONFIG_MONGODB_ADMINPASSWORD: <password>
ME_CONFIG_MONGODB_URL: mongodb://<username>:<password>@mongodb:27017/<database>?authSource=admin
depends_on:
- mongodb
docker compose up -d
This will start the web application, MongoDB, and Mongo Express using the configuration in your docker-compose.yaml file and environment variables.
NODE_ENV (default: Production)MONGO_URL (required): MongoDB connection stringlocalhost:3000: Applicationlocalhost:8081: Mongo Expressš§š»āš» Developed and maintained by Pranjal Singhā
Content type
Image
Digest
sha256:a0ce770f8ā¦
Size
51.1 MB
Last updated
over 1 year ago
docker pull prancodes/contact-form