Search code examples
dockergithubgithub-actions

Docker runs locally but not on Github actions :No such file or directory


My docker files run locally without any problem , but when i do github actions workflow it gives error I have been through lot of posts but couldnt find proper solution. Been on it for like 2 days

i am attaching my docker and workflow file below, i think its related to working directory issue or is it related to permission.

ERROR: failed to solve: process "/bin/sh -c chmod +x /app/wisecow/wisecow.sh" did not complete successfully: exit code: 1 Error: buildx failed with: ERROR: failed to solve: process "/bin/sh -c chmod +x /app/wisecow/wisecow.sh" did not complete successfully: exit code: 1

My workflow file

name: Publish Docker image

on:
  push:
  release:
    types: [published]
    defaults:
        run:
           working-directory: ./app
jobs:
  push_to_registry:
    name: Push Docker image to Docker Hub
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
      # This is used to complete the identity challenge
      # with sigstore/fulcio when running outside of PRs.
      id-token: write

    steps:
      - name: Check out the repo
        uses: actions/checkout@v4

      - name: Log in to Docker Hub
        uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
        with:
          images: mrallena/cowsay



      - name: Build and push Docker image
        uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

My DOCKER file

# Use a base image
FROM ubuntu:latest

RUN apt-get update && apt-get install fortune-mod cowsay -y && apt-get install netcat -y
ENV PATH="/usr/games:$PATH"

# Set the working directory
WORKDIR /app/wisecow

# Copy the shell script into the image
COPY wisecow/ /app/wisecow

# Make the script executable (if needed)
RUN chmod +x /app/wisecow/wisecow.sh
# Define the default command to run when the container starts
CMD ["sh", "-c", "./wisecow.sh"]

BUILD TO BE SUCCESSFUL


Solution

  • it worked, the problem was i somehow had a submodule in one of my directory , so removing it worked