docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.11k stars 526 forks source link

Not all files present in final build when using `context` #1084

Closed onel closed 3 months ago

onel commented 3 months ago

Contributing guidelines

I've found a bug, and:

Description

The build and push step seems to ignore some files that were created beforehand. I have a step that runs an npm run build that creates some js files, but those files do not seem to be in the resulting image.

I've added a debug step that runs an ls to check if the files are created I use the context: . option .dockerignore doesn't seem to be the problem

Expected behaviour

That the final docker image contains the newly created files

Actual behaviour

Files are missing

Repository URL

https://github.com/peermetrics/web

Workflow run URL

https://github.com/peermetrics/web/actions/runs/8388367909/job/22972403440

YAML workflow

name: Docker Hub

on:
  push:
    branches:
      - 'master'

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - 
        name: Checkout repository
        uses: actions/checkout@v4

      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - 
        name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '16.x'

      - name: ls dir
        run: ls -al static/js/app-dashboard

      - 
        name: Install dependencies
        run: npm install

      - 
        name: npm Build
        run: npm run build

      -
        name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: ls dir
        run: ls -al static/js/app-dashboard

      -
        name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: .
          tags: peermetrics/web:latest
          push: true

      - name: Logout from Docker Hub
        run: docker logout

Workflow logs

No response

BuildKit logs

No response

Additional info

I've tried multiple other options before opening this issue. Weirdly enough the node_modules folder created with run: npm install is present in the final image so I'm not sure where the issue is coming from

onel commented 3 months ago

Still haven't figured out the cause of the issue but closing, as it might be from somewhere else.