Skip to content

JerryMSFT/OSS-DEMO-JR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Deploy Voting App

Prerequisites

To complete this tutorial you will need: tt

  1. Git
  2. Azure CLI or use Azure Cloudshell
  3. Docker for Mac or Docker for Windows -- see Docker.com for other installs
  4. Docker Hub Account -- Free account for public image storage

This tutorial assumes you have an active Azure Subscription, otherwise a free trial can be used (or using the Free Tier of App Service).

If you don't have an Azure subscription, create a free account before you begin.

You should already have this sample code downloaded but if not:

Clone this repo:

git clone git@github.com:alihhussain/WhatTheHack.git

Switch to the correct folder:

cd app

Test and Run Container Locally

If you are new to Docker and containers, it would be helpful to review the following Getting Started Guide on Docker.com. If you are new to containers in general, please also read What is a Container? on Docker.com.

Now lets build the docker image. To do so you will need a Docker Hub account (linked above in the prereqs) and a public repository.

From the app folder, run the following command replacing <DockerHubUsername> with your Docker Hub user name.

docker build -t <DockerHubUsername>/<AppName> .

For instance:

docker build -t="alihhussain/voting-app:v1" .

Let's review what happened:

  • docker - the Docker daemon/engine that runs, manages, and creates Docker images
  • build - the build command tells Docker to get ready to build a Docker image based on a Dockerfile.
  • -t - we need to tag our image with our user name so that we push to Docker Hub it is accept correctly
  • <DockerHubUsername>/voting-app - the name of our Docker Hub account and the name of the app (e.g. voting-app) we want to name it.
  • . - the dot is used to mean "current directory", in this case it provides the build command reference to find the Dockerfile.

Once build finishes, you can view local images using the following command:

docker images

Output should look like:

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
alihhussain/votingapp   v1                  60c341b2af89        39 seconds ago      89.3MB

Test the application functions locally using the following Docker command:

docker run -p 80:80 alihhussain/voting-app:v1

That command maps the exposed port of 80 from within the container to the host's port of 80. Now you can see it at

You can exit the container with CTRL+C.

Now that we have tested our application locally, let's push this to the Docker Hub so that Web App for Containers will receive it.

To do so you will have to login within your Docker environment and enter your username and password, to do so run the following command:

docker login

Lets now push the image up to DockerHub

docker push <DockerHubUsername>/voting-app:v1

It will look something like this:

docker push alihhussain/voting-app:v1

The image we pushed is public and now downloadable via Docker Hub to any machine or server. In a production scenario, you would have a private container registry like Azure Container Registry. You can find details here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published