How to create a docker file for angular application to host on azure container instance

Rahul Mishra 20 Reputation points
2024-11-18T13:00:24.9733333+00:00

How to create a docker file for angular application to host on azure container instance

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
465 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
713 questions
{count} votes

Accepted answer
  1. Srinud 2,720 Reputation points Microsoft Vendor
    2024-11-18T16:54:30.5033333+00:00

    Hi Rahul Mishra,
    Thank you for reaching out to us on the Microsoft Q&A forum.
    Based on the description for creating a Dockerfile to deploy an Angular application, you need to use a Node.js image as the base image. Below is a sample Dockerfile for your reference please replace the instruction values with your own data.

    FROM ubuntu:20.04 AS build
    RUN git clone <code_url> && cd /directory
    COPY package.json package-lock.json ./
    RUN npm install
    RUN npm run build --prod
    FROM nginx:alpine
    COPY --from=build /app/dist/your-app-name /usr/share/nginx/html
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]
    

    Once the docker file is created to build and push the docker image run the following commands.

    docker build -t <imge_name> .
    docker tag <imge_name> your-registry-name/<new-imge_name>:<tag_name>
    docker push your-registry-name/<new-imge_name>:<tag_name>
    

    Once the docker image is created and pushed to docker registry, to deploy that image to azure conainer instance run the below command.

    az container create \
      --resource-group <your-resource-group> \
      --name <your-container-name> \
      --image < your-registry-name/<new-imge_name>:<tag_name > \
      --cpu 1 --memory 1.5 --ports 80
    
    

    If the information is helpful, please consider by clicking the " Accept answer and Upvote " on the post.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.