Set up a Dockerfile for your angular application with Nginx
Oumayma JavaScript Developer
Posted on January 16, 2022
Running your application in docker container is the first step towards production. We have to make sure that our app can build successfully , independently of our local environment.
Bellow you can find a basic dockerfile for your angular application that uses nginx server to render the html.
FROM node:12-alpine as build
WORKDIR /app
COPY package.json .
RUN yarn install
COPY . .
RUN apk add gettext
RUN yarn build --base-href
FROM nginx:latest
COPY --from=build /app/dist/hr-frontend /usr/share/nginx/html
EXPOSE 80
The above dockerfile will run your application on port 80.
To test it, in the root of your project run:
docker image build --tag <your image name> .
-
docker run -d -p 8000:80 <your image name>
This command will serve your application on port 8000. The port 80 is where your application is running inside the container. - Go to localhost:8000 .
💖 💪 🙅 🚩
Oumayma JavaScript Developer
Posted on January 16, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.