In this demo, we will deploy a simple Hello World NodeJS web app. DuploCloud pulls Docker images from Docker Hub. You can choose a public image or provide credentials to access your private repository. For the sake of this demo, we will use a ready-made image available on Duplo’s repository on Docker Hub.
Create a host #
- Login to your DuploCloud console.
- Select DevOps > Hosts, a Host is the instance in which your Docker container will run. You should choose a host with appropriate processing capacity for your application.
- Click on the +Add button to choose your host. Fill out the advanced options form if required and click submit.
You should now see your Host present in the table. Please give it a moment to instantiate.
Create a service #
- Next, we can create a Service. A Service is nothing but a container with user specified image and environment variables. Let’s go ahead and click +Add button to create a new service.
- Name the service “
Test-service“. For this demo we will use the latest, nodejs-hello image from Duplo’s public Docker hub repository. Fill in “
duplocloud/nodejs-hello:latest” in the Docker Image field.
- Enter the desired number of replicas you want in the swarm. Please note that each replica runs in an individual Host, so the number of replicas must equal the number of Hosts. For the sake of this demo, we will choose 1.
- Fill in the desired environment variables, this is ideal for credentials or application specific configurations.
- Volume mapping is super easy, simply give the host path and container path as shown. Please note that we highly recommend keeping the Hosts stateless and using S3 for static assets. We will keep this field empty for this demo.
Press create and wait a moment for the service to initialize.
Create a load balancer #
- Since the hello-nodejs image serves on port 3000 we need to create a load balancer (LB) configuration to map external port (LB) to internal port (container).
- Select the Test-service and click on configure load balancer on the load balancer tab. Fill the menu as shown below and click submit. This will also create a DNS name that we can use.
Please wait for ~5 minutes as it can take a while for the DNS Route table changes to be reflected.
Preview the application #
Expand Test-service and copy the URL displayed under DNS. Hit the URL in the browser and You should see the Hello world serving our welcome message.
Congratulations! You have just launched your first web service on Duplo!