From 3ec0a4d70db670fe81384bf06e275a510aabdde9 Mon Sep 17 00:00:00 2001 From: sveitser Date: Tue, 12 Nov 2024 12:25:38 +0100 Subject: [PATCH] Use path context instead of git context With the default git context the repository is re-cloned at the start of the docker build and the .dockerignore file is ignored. > Be careful because any file mutation in the steps that precede the > build step will be ignored, including processing of the .dockerignore > file since the context is based on the Git reference. https://github.com/docker/build-push-action?tab=readme-ov-file#git-context This leads to some `.git` worktree files showing up inside the dockerbuild with triggers a bug in yarn. See https://github.com/yarnpkg/yarn/issues/7537#issuecomment-1099584308 for more details about the yarn bug. --- .github/actions/docker-image/action.yml | 4 ++++ .github/workflows/espresso-docker.yml | 7 ++----- Dockerfile | 4 +--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/actions/docker-image/action.yml b/.github/actions/docker-image/action.yml index c84073f225..e2a34d66b6 100644 --- a/.github/actions/docker-image/action.yml +++ b/.github/actions/docker-image/action.yml @@ -1,6 +1,9 @@ name: Espresso Docker Image inputs: + context: + required: true + type: string images: required: true type: string @@ -36,6 +39,7 @@ runs: uses: docker/build-push-action@v5 id: build with: + context: ${{ inputs.context }} file: ${{ inputs.file }} target: ${{ inputs.target }} labels: ${{ steps.metadata.outputs.labels }} diff --git a/.github/workflows/espresso-docker.yml b/.github/workflows/espresso-docker.yml index a5f6a00d82..371fb384b0 100644 --- a/.github/workflows/espresso-docker.yml +++ b/.github/workflows/espresso-docker.yml @@ -89,11 +89,6 @@ jobs: with: submodules: recursive - # TODO shouldn't need this - - name: Clean up Git worktree files - run: | - find . -type f -name '.git' -print -exec rm -f {} \; - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -107,6 +102,7 @@ jobs: - name: Build nitro-node image uses: ./.github/actions/docker-image with: + context: . file: Dockerfile images: ghcr.io/espressosystems/nitro-espresso-integration/nitro-node target: nitro-node @@ -116,6 +112,7 @@ jobs: uses: ./.github/actions/docker-image id: nitro-node-dev with: + context: . file: Dockerfile images: ghcr.io/espressosystems/nitro-espresso-integration/nitro-node-dev target: nitro-node-dev diff --git a/Dockerfile b/Dockerfile index 587945ae76..53717933ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,9 +33,7 @@ COPY contracts/package.json contracts/yarn.lock contracts/ RUN cd contracts && yarn install COPY contracts contracts/ COPY safe-smart-account safe-smart-account/ -# Check if there are any unexpected .git directories or worktree files -RUN find . -type d -name ".git" -printf "%p DIR\n" -o -type f -name ".git" -printf "%p FILE\n" && exit 1 -RUN cd safe-smart-account && yarn install --verbose +RUN cd safe-smart-account && yarn install COPY Makefile . RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity