CodexBloom - Programming Q&A Platform

GitHub Actions scenarios to find Dockerfile in a multi-stage build setup

👀 Views: 1638 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
github-actions docker ci-cd yaml

Does anyone know how to I've hit a wall trying to I've been banging my head against this for hours. Quick question that's been bugging me - I've been banging my head against this for hours. I'm having trouble getting my GitHub Actions workflow to properly build my Docker images using a multi-stage build setup. I have a project that uses a Dockerfile to build a production image, and I also have a separate Dockerfile for testing. My folder structure looks like this: ``` my-project/ │ ├── Dockerfile ├── test.Dockerfile ├── app/ │ └── main.py └── .github/ └── workflows/ └── docker_build.yml ``` In my `docker_build.yml`, I'm attempting to reference the `Dockerfile`, but I keep getting the following behavior in the Actions logs: ``` fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` Here's the relevant snippet of my `docker_build.yml`: ```yaml name: Build Docker Image on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Build Docker image run: | docker build -t my-image:latest . docker build -f test.Dockerfile -t my-image:test . ``` I've verified that the Dockerfiles exist in the expected locations, and I have the right permissions set for the repository. Also, my Dockerfile builds correctly when I run it locally using `docker build .`. I've tried changing the context path in the Docker build command, but that didn't resolve the scenario. Could this be due to the context of the build command being set incorrectly when running in GitHub Actions? Any suggestions on how to troubleshoot this or modify my workflow to ensure it finds the Dockerfile correctly? This is part of a larger API I'm building. I'm working on a web app that needs to handle this. My team is using Yaml for this desktop app. I'd really appreciate any guidance on this. The project is a REST API built with Yaml. The stack includes Yaml and several other technologies.