DevOps Classroom notes 05/Feb/2025

Exercise:

  • Build a docker image for the following repo
  • Manual steps:
    • Ensure node js and npm are installed
    • execute npm install this will install dependencies
    • execute npm run build which generates a folder called dist
    • execute npm run preview this should run the application
  • First write the docker file for this
FROM node:20-alpine
LABEL project="learning"
ARG USERNAME=chess
RUN adduser -D -h /apps -s /bin/sh ${USERNAME}
USER ${USERNAME}
WORKDIR /apps
COPY --chown=${USERNAME}:${USERNAME} . /apps/
RUN npm install && npm run build
EXPOSE 4173
CMD ["npm","run","preview","--", "--host", "0.0.0.0"]
  • Refer Here for application
  • Use multi staged build
    • Ensure node js and npm are installed
    • execute npm run build which generates a folder called dist
    • Copy this folder into nginx and then the application will work on port 80
  • Refer Here for the latest changes in Dockerfile

Docker Security Best Practices

  • Run as a non root user
  • Prefer using Distroless images
    • jdk: gcr.io/distroless/java17-debian12
    • aspdotnetcore: mcr.microsoft.com/dotnet/aspnet:9.0
  • Try rebuilding spc and nop using the above images in final stage.

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube