ervisp / DevSecOps-Project

0 stars 0 forks source link

Repository missing correct file used by building the image "Dockerfile" missing yarn.lock #1

Open ndricimdanaj opened 1 month ago

ndricimdanaj commented 1 month ago

FROM node:16.17.0-alpine as builder WORKDIR /app COPY ./package.json . COPY ./yarn.lock . RUN yarn install COPY . . ARG TMDB_V3_API_KEY ENV VITE_APP_TMDB_V3_API_KEY=${TMDB_V3_API_KEY} ENV VITE_APP_API_ENDPOINT_URL="https://api.themoviedb.org/3" RUN yarn build

FROM nginx:stable-alpine WORKDIR /usr/share/nginx/html RUN rm -rf ./* COPY --from=builder /app/dist . EXPOSE 80 ENTRYPOINT ["nginx", "-g", "daemon off;"]

image

ervisp commented 1 month ago
  1. Check File Existence Ensure that the yarn.lock file exists in the context of your Docker build. The Docker build context is the directory from which you run the docker build command. If the yarn.lock file is not present in the same directory as your Dockerfile, the build will fail. Verify the presence of yarn.lock: ls -l ./yarn.lock
  2. Correct Build Context Make sure you are running the docker build command from the correct directory where your Dockerfile and yarn.lock file are located. For example, if your directory structure looks like this: /my-app ├── Dockerfile ├── package.json ├── yarn.lock └── src You should run the following command from the /my-app directory: docker build -t your_image_name .
  3. Update Dockerfile : If you have confirmed that the yarn.lock file exists and you are in the correct directory, ensure that your Dockerfile is correctly set up to copy the file. Your Dockerfile should include the following lines: COPY ./package.json . COPY ./yarn.lock .
  4. Clean Docker Build Cache Sometimes, Docker's build cache can cause issues. You can try building the image without using the cache: docker build --no-cache -t your_image_name .
  5. Verify Docker Installation Ensure that your Docker installation is functioning correctly. You can check the Docker version and status: docker --version docker info
  6. Check for Docker Daemon Issues If the problem persists, ensure that the Docker daemon is running correctly. If you are on a Linux system, you can check the status with: sudo systemctl status docker
ndricimdanaj commented 1 month ago

yarn.lock is missing in the source code... Builing the image fails without yarn.lock file

image