I have a GitHub actions CI which builds a my app in the last version of this app .git directory is mandatory for building it the problem is that GitHub action don't remove it in the docker build step of the CI.
Here is my CI template:
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/3.3.5-MV'
steps:
- uses: actions/checkout@v2
-
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.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
file: ./Dockerfile
tags: foo/bar:latest
push: true
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
The Dockerfile
FROM ubuntu:focal
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update && apt upgrade -y && apt install -y [all my dependencies]
WORKDIR /usr/src/app
COPY . .
WORKDIR /usr/src/app/build
#default path on docker image /usr/local
RUN cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local/ -DTOOLS=0
RUN make -j $(nproc) install
WORKDIR /usr/local/bin
Dockerfilecontrols what gets installed in your image. What does yourDockerfilelook like?Dockerfilebut as it works by the past and it works locally. But in the last version of the app,.githas became mandatory to be able to build. I checked the previously image created by GitHub action and thegitrepository is removed automatically by GitHub action. I thinkuses: actions/checkout@v2copy everything except that to minimise the weight of the image.#12 1.009 fatal: not a git repository (or any of the parent directories): .git