Skip to content

Commit

Permalink
Use path context instead of git context
Browse files Browse the repository at this point in the history
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 yarnpkg/yarn#7537 (comment)
for more details about the yarn bug.
  • Loading branch information
sveitser committed Nov 12, 2024
1 parent 8a3ba93 commit 3ec0a4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/actions/docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Espresso Docker Image

inputs:
context:
required: true
type: string
images:
required: true
type: string
Expand Down Expand Up @@ -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 }}
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/espresso-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3ec0a4d

Please sign in to comment.