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 comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%