GH Action to Build and Deploy to AWS ECS Failing

  • What Grafana version and what operating system are you using?

Working in Grafana main branch at this commit fef490e

Working from Windows, building Docker container.

  • What are you trying to achieve?

We are trying to automate building and pushing a container image to Amazon ECR. Then we would like to deploy the application using AWS ECS.

  • How are you trying to achieve it?

1.Mirrored the official Grafana repository
2.Removed “.git” from .dockerignore
3.Tested building locally with no problems: docker build -t grafana-app .
4.Setup the Github Action: Amazon ECS “Deploy Task Definition” Action.
5. Started the workflow and it failed with the following error:

Step 47/67 : COPY ${GRAFANA_TGZ} /tmp/grafana.tar.gz
COPY failed: file not found in build context or excluded by .dockerignore: stat grafana-latest.linux-x64-musl.tar.gz: file does not exist
Error: Process completed with exit code 1.

6.I also tried to remove “/tmp” from .dockerignore but I still received the error.

  • What did you expect to happen?

We expected the docker container to build, push, and then deploy to ECS because it works when we attempted this manually (without the Github Action).

Why would the file be found when we run build locally but not through the Github Action?

Are there any suggestions on what to do or how to further debug this issue?

Thanks!

Update: I created a reduced GH action that just attempts to build the docker container image, and I get the same error at step 47/67. Here is the action script:

name: Build Grafana Container Image

on:
  push:
    branches: [ "main" ]

permissions:
  contents: read

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    environment: production

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Build docker container
      id: build-image
      run: |
        docker build -t grafana-app .

My .dockerignore file is as follows:

.awcache
.dockerignore
.gitignore
.vscode
bin
data*
dist
docker
Dockerfile
docs
dump.rdb
node_modules
**/node_modules
*.yml
!.yarnrc.yml
*.md
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/versions
!.yarn/cache

Update: Using docker buildx build fixed the issue. I came across someone who was having this issue with their Azure pipeline.

During the building of a linux Docker image using the Dockerfile in the root the file 'ARG GRAFANA_TGZ=“grafana-latest.linux-x64-musl.tar.gz” cannot be found · Issue #61347 · grafana/grafana (github.com)

1 Like