-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build from Dockerfile in subdirectory #169
Comments
This is not a valid syntax in a workflow. You change the context to |
I see, I modified my script according to #166 and its working. |
I'll try changing the context and close the issue soon. |
I've changed context to ./apis/report-api but it fails to build, says following error:
|
So it looks like |
It does. |
@digz6666 Do you have a link to your repo? |
Its private repo. I'll make a small public repo and tell you later :) |
@digz6666 did you find a solution ? |
I've replaced this:
with following:
|
OK actually, on my side, I had to duplicate context for Dockerfile path: - name: Build & push image
uses: docker/build-push-action@v2
with:
context: ./build/front
file: ./build/front/Dockerfile |
This works for me, thanks! |
Seems like I have a similar issue. I am using v3. https://github.com/jkulak/spotify-grabtrack/actions/runs/2899683281
|
I have the same problem with v3.1.1
I tried different paths as well:
|
@jcnils did you resolve this? I'm pulling out my hair trying to use a Dockerfile from a subdirectory... |
@rbluethl have a look here: https://github.com/jkulak/smartplaylist-backend/blob/main/.github/workflows/build-docker-images.yaml#L14-L36 I had to add
and later I could use
|
Thanks for your help @jkulak! :) Interestingly enough, I just tried without the checkout action and it now works even without it. For everyone struggling with this in the future, this is would I ended up with. name: Build and push prod
on:
push:
tags: ['v*']
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=<image>
VERSION=main
SHA=${GITHUB_SHA::7}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:main"
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.sha }})
fi
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-$SHA"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=sha::${SHA}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push backend
uses: docker/build-push-action@v3
with:
context: ./backend
push: true
tags: ${{ steps.prep.outputs.tags }}
build-args: VERSION_SUFFIX=${{ steps.prep.outputs.sha }} |
Just to be sure, does it work without the |
The funny thing is that this step had been there all the time, so I can't tell what the problem was before that. :( |
For me it worked also only after adding this |
For me it only worked after adding the checkout step at the beginning. |
Anyone running into this with similar issues using |
I'd like to build the Dockerfile in following path apis/report-api/Dockerfile and push to amazon-ecr.
But COPY command in Dockerfile fails because it needs to run from the sub directory.
I've tried setting working-directory option but its saying: Unexpected value 'working-directory'.
Maven build is working fine, how can build docker image and push?
Here's files in my project structure:
Here's the apis/report-api/Dockerfile
Here's the action yml file:
The text was updated successfully, but these errors were encountered: