I have a Next.js project which I'm creating a docker image from, and then publishing to Azure Container Registry via Github Actions.
My Dockerfile is as follows:
FROM node:12.3.1-alpine
WORKDIR /app
COPY . /app
RUN ["npm", "install"]
RUN ["npm", "run", "test:ci"]
RUN ["npm", "run", "build"]
EXPOSE 80 443
CMD ["npm", "start"]
So it's not that complicated. Just to mention that early I've also tried COPY . .
My intent is to copy everything in the CWD to the /app
folder. This includes several files and directories, including a folder called public
which contains a couple of static files.
When I build it locally it copies everything including the public
folder. When I run this through Github Actions and push it to Azure Container Registry, everything is kept, except the public
folder.
Just to mention, I tried copying the public
folder naming it something random and then pushing both the public
folder and the copied one. The pipeline ran successfully and the image was published to ACR.
I then pulled the newly pushed image down locally and everything was there including the random folder except the public
folder!
For clarity I checked that running docker run -it -p 3000:80 <registry-name>.azurecr.io/<image-name>:<tag> sh
after pulling it, and then ls -la
.
So, somewhere along the line the public
folder is filtered out. Next.js has a convention that forces me to name this folder 'public'.
Relevant Github Actions lines:
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and push image
run: |
docker login $ACR_NAME -u $ACR_USER -p $ACR_PASSWORD
docker build . --tag "$ACR_NAME/$REPO_NAME:latest" --tag "$ACR_NAME/$REPO_NAME:${{github.run_number}}"
docker push $ACR_NAME/$REPO_NAME:${{github.run_number}}
I've tried google'ing, but either I'm using the wrong search terms or there hasn't been anyone running into this yet.
What's going on? The Dockerfile
seems to be working (based on local results). I feel the one to "blame" here is Github Actions that's where the image is built when it goes wrong, but I don't know.