Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout isn’t working #120

Closed
ThisIsQasim opened this issue Sep 12, 2020 · 5 comments
Closed

Checkout isn’t working #120

ThisIsQasim opened this issue Sep 12, 2020 · 5 comments

Comments

@ThisIsQasim
Copy link

ThisIsQasim commented Sep 12, 2020

Behaviour

As per the docs, it should automatically checkout the repo before building the docker image. I am building an image with a build context of a subfolder and the working directory is empty.

Steps to reproduce this issue

  1. Try to build an image with a context other than .
  2. Build will fail citing missing directory

Expected behaviour

Repo should be cloned and build should succeed.

Actual behaviour

Repo is not cloned and build fails

Configuration

name: Docker Image CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:

    runs-on: ubuntu-latest

    steps:
    - name: Set up QEMU
      uses: docker/setup-qemu-action@v1
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1
    - name: Login to DockerHub
      uses: docker/login-action@v1 
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
    - name: Set current directory
      run: |
        pwd; ls; ls ..
    - name: Build and push
      id: docker_build
      uses: docker/build-push-action@v2
      env:
        VERSION: '7.8.0'
        ODFE_VERSION: '1.9.0.2'
        REPO: thisisqasim
      with:
        context: elasticsearch
        file: elasticsearch/Dockerfile
        build-args: VERSION=${{ env.VERSION }},ODFE_VERSION=${{ env.ODFE_VERSION }}
        platforms: linux/amd64,linux/arm64
        pull: true
        push: true
        tags: ${{ env.REPO }}/elasticsearch:${{ env.VERSION }}
    - name: Image digest
      run: echo ${{ steps.docker_build.outputs.digest }}
@crazy-max
Copy link
Member

@ThisIsQasim

As I can see you're using a path context context: elasticsearch so in your case you have to checkout before using this action.

If you want to rely on Git context to allow buildx to checkout the repository for you, remove the context input.

@ThisIsQasim
Copy link
Author

Can I change the context to a directory using git context?

@crazy-max
Copy link
Member

@thaJeztah

Can I change the context to a directory using git context?

A way to define a subdir would be to use:

context: https://github.com/${github.context.repo.owner}/${github.context.repo.repo}#${github.context.ref}:my/subdir

But this is not yet supported. I will add a note in the README about this.

@ThisIsQasim
Copy link
Author

I think it's easier and cleaner to just clone in a separate step

@thaJeztah
Copy link
Member

But this is not yet supported. I will add a note in the README about this.

Ah, interesting; I didn't know it was not yet supported in BuildKit. I opened a tracking issue for that; moby/buildkit#1684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants