I'm using github actions to do a build and push for an image to my google artifact registry.
There's a number of steps in the workflow, to condense it down to what's relevant...
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Authenticate to google cloud
uses: (external workflow... redacted...)
- name: Download workspace data
uses: actions/download-artifact@v3
(this step pulls down a folder from a previous workflow, containing the .next folder)
- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: ${{ inputs.build_arm && 'linux/amd64,linux/arm64' || 'linux/amd64'}}
tags: ${{ inputs.image_name }}:${{ inputs.image_tag }}
build-args: |
${{secrets.build-args}}
${{inputs.build-args}}
secrets: |
${{secrets.build-secrets}}
In the working directory (and docker context) for the build, there is a folder called next
which contains another hidden folder called .next
.
The Dockerfile has a step:
COPY next /opt/auth-service/next
The problem
My issue is, during the build-and-push stage, the COPY stage above copies all the contents of the next
folder apart from the hidden folder and I can't seem to find out why.
What I've tried
I've used tmate (mxschmitt/action-tmate@v3
) to SSH into the github action runner just before the build/push step and can confirm the folder next/.next
is present. Whilst on the github runner I can also run docker build -t <image-name> .
and then when I download that image to my laptop and run it - the next/.next folder is there. Just not when it's build by the docker/build-push-action@v3
action.
Any ideas why this could be?
The docs for docker/build-push-action@v3
says:
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. However, you can use the Path context using thecontext
input alongside theactions/checkout
action to remove this restriction.
You need to add the context: .
:
jobs:
docker:
steps:
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .