0

i need to build and push my docker image on dockerHub but i'm getting error on path Dockerfile.

i had learn other (Build Docker image using GitHub Actions: No such file or directory) but i don't understand how can resolve this error.

service:
      runs-on: ubuntu-latest
      defaults:
        run:
          working-directory: ./microservices/service

      strategy:
        matrix:
          node-version: [16.x]

      steps:
      - name: CHECK-OUT GIT REPOSITORY
        uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
          cache-dependency-path: '**/package-lock.json'
      - name: INSTALL DEPENDENCIES
        run: npm ci
      - name: BUILDING APP
        run: npm run build --if-present
      #- name: TESTINT APP
      #- run: npm test
      - name: Build & push Docker image
        uses: mr-smithers-excellent/docker-build-push@v5
        with:
          image: dockercountname/aos_movie_service
          tags: latest
          registry: docker.io
          dockerfile: Dockerfile
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

My Local directory: i have many subForlder for each service and each service contains his Dockerfile.

microservice_cicd(forlder)
   microservices(forlder)
     service1(forlder)
       package.json
       Dockerfile
       ...
     service2(forlder)
       package.json
       Dockerfile
       ...

This is my Dockerfile:

FROM node:latest
RUN mkdir -p /src/app
WORKDIR /src/app
COPY package.json /src/app/package.json
RUN npm install
COPY . /src/app
EXPOSE 3003
CMD [ "npm", "start" ]

3
  • Well where is your DockerFile Commented Oct 30, 2022 at 15:34
  • Thank you for you answer. My Dockerfile is in microservice_cicd>microservices>service>Dockerfile. Commented Oct 31, 2022 at 6:46
  • Hello, i have get other error actually, Step 4/7 : COPY ./package.json ./ COPY failed: file not found in build context or excluded by .dockerignore: stat package.json: file does not exist I seaching solution. Don't hesitate someone can help me. Commented Nov 1, 2022 at 20:08

1 Answer 1

1

finally i had find a solution.

Workflow

  AuthService:
      runs-on: ubuntu-latest
      defaults:
        run:
          working-directory: ./microservices/AuthService

      strategy:
        matrix:
          node-version: [16.x]

      steps:
      - name: CHECK-OUT GIT REPOSITORY
        uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
          cache-dependency-path: '**/package-lock.json'
      - name: INSTALL DEPENDENCIES
        run: npm ci
      - name: BUILDING APP
        run: npm run build --if-present
      #- name: TESTINT APP
      #- run: npm test
      - name: Build & push Docker image
        uses: mr-smithers-excellent/docker-build-push@v5
        with:
          # directory: /microservices/AuthService
          image: dockerHubCountName/aos_movie_auth_service      
          tags: latest
          registry: docker.io
          dockerfile: microservices/AuthService/Dockerfile
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

Dockerfile

FROM node:latest
RUN mkdir -p /src/app
WORKDIR /src/app
COPY microservices/SearchService .
RUN npm install
EXPOSE 3003
CMD [ "npm", "start" ]

Thank you.

Sign up to request clarification or add additional context in comments.

1 Comment

But locally if need to build your image don't forget replace COPY microservices/SearchService . by COPY . .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.