This website application was my project on my Assestment on Cloud Engineer to showcase my skills on Docker and Azure Container.
Key Technologies
- Front End: .Net
- Container: Docker and Azure Container.
This project showcases my ability to integrate various technologies to build a complete and functional application using Docker and Azure Container.
Docker Installation and Project Setup
- Create Azure Container Registry: Go to the Azure Dashboard, search for “Container Registry”, and create a new one. Enter the required information on the “Basic” tab. You can skip Networking, Encryption, and Tags, leaving them at their default values, then click “Review and Create”.
- Install Docker: Go to the Docker website and download Docker Desktop.
Dockerfile Creation with .NET
- Create a project directory and run the following command in your terminal:
dotnet new mvc -n HelloWebApp - Run the .NET project to test it:
dotnet run - Copy the
localhostlink provided and paste it into your browser. - Create a file named
Dockerfilein the root of your project directory with the following content:
# Use .NET 7.0 runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["HelloWebApp/HelloWebApp.csproj", "HelloWebApp/"]
RUN dotnet restore "HelloWebApp/HelloWebApp.csproj"
COPY . .
WORKDIR "/src/HelloWebApp"
RUN dotnet build "HelloWebApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "HelloWebApp.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HelloWebApp.dll"]
Image Build and Verification
- Build the Docker image:
docker build -t hellowebapp . - Run the container to verify it works:
docker run -p 8080:80 hellowebapp
Push to Azure Container Registry
- Log in to your Azure Container Registry. You can find the credentials under “Access keys” in the Azure portal.
docker login ronaldbarueloregistry.azurecr.io --username ronaldbarueloregistry --password <your-password> - Tag the Docker image for your registry:
docker tag hellowebapp ronaldbarueloregistry.azurecr.io/ronaldbaruelo/hellowebapp:latest - Push the image to the Azure Container Registry:
docker push ronaldbarueloregistry.azurecr.io/ronaldbaruelo/hellowebapp:latest