Docker + Angular

Docker + Angular

Here is a simple tutorial to get an Angular app up and working on docker

  • Install docker on your local to run this locally here
  • Go to your repos folder. This an area not specific but just on your local computer where you usually create projects.
  • Open the terminal and run. This will create a new Angular app

ng new ngDocker
        

  • Open VSCode
  • Add the Docker extension if you don't have it already here
  • Add to the root of your project 2 files : "DockerFile" and ".dockerignore"
  • Set the contents of the "DockerFile" to the following

FROM node:12.7-alpine AS build
WORKDIR [change here to your root folder of project]
COPY package.json package-lock.json ./
RUN npm cache clean --force
RUN npm i
COPY . .
RUN npm run build


FROM nginx:1.17.1-alpine

COPY --from=build [change here to root of build folder] [set here output path]
        

  • Here is how to start the image you just built

No alt text provided for this image

  • Then run the application in the browser

No alt text provided for this image

  • Here is what your app will look like in the browser

No alt text provided for this image


Here are some good resources


To view or add a comment, sign in

Explore content categories