Skip to content

.git missing inside container? #378

@bastelfreak

Description

@bastelfreak

Troubleshooting

Before sumbitting a bug report please read the Troubleshooting doc.

Behaviour

Steps to reproduce this issue

  1. Create a Dockerfile with RUN git describe --always > VERSION
  2. See it working locally
  3. see it failing on github actions

Expected behaviour

I expect that this works properly

Actual behaviour

I see the following in the error log:

#10 [ 7/11] RUN git describe --always > VERSION
#10 sha256:50f59aab7c36de632d818d4b6c44ba392fbde9110e40393f9834bd372996bc46
#10 0.093 fatal: not a git repository (or any of the parent directories): .git
#10 ERROR: executor failed running [/bin/sh -c git describe --always > VERSION]: exit code: 128
------
 > [ 7/11] RUN git describe --always > VERSION:
------
Dockerfile:13
--------------------
  11 |     ADD . /vpt
  12 |     
  13 | >>> RUN git describe --always > VERSION
  14 |     
  15 |     RUN gem install bundler \
--------------------
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c git describe --always > VERSION]: exit code: 128
Error: buildx call failed with: error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c git describe --always > VERSION]: exit code: 128

Configuration

name: test-build-release

on:
  push:
    branches: master

jobs:
  test:

    runs-on: ubuntu-latest
    env:
      BUNDLE_WITHOUT: development

    steps:
    - uses: actions/checkout@v2
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.7
        bundler-cache: true
    - name: Run tests
      run: bundle exec rake rubocop
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1
    - name: Login to DockerHub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_TOKEN }}
    - name: Build and push Docker images
      uses: docker/build-push-action@v2
      with:
        push: true
        tags: latest

Logs

build.log

My guess here is that the .git directory is not available within the container. I did some digging in the code I'm not sure if my guess is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions