devcontainers / devcontainers/ci
cache miss
- Vorherrschende Sprache
- TypeScript
- Sterne
- 496
- Forks
- 101
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hoping to get some guidance 🙏
In my workflow I have a separate job that builds a test image in CI off of a base production image using docker's build-push action. That image then gets pushed to GCR and subsequent steps pull to run tests. I'm noticing that for the first devcontainer action it'll rebuild the container from scratch everytime, even though the cache is being stored in line. looking at the docker build command shows

Could someone point out where my configuration may be incorrect?
Here is my workflow, (i've omitted some steps that I don't believe to be related to the issue):
```
jobs:
pre-build:
runs-on: ubuntu-latest
outputs:
run_attempt: ${{ github.run_attempt }}
env:
SHA: ${{ github.event.pull_request.head.sha }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Short GitHub SHA
run: echo "SHA7=${SHA::7}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to GCR
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ env.SERVICE_KEY_FILE }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:dbt"
pull: true
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.DATASET }}.gh-${{ github.run_id }}.${{ github.run_attempt }}
${{ env.IMAGE_NAME }}:${{ env.SHA7 }}
cache-from: type=gha
cache-to: type=gha,mode=max,type=inline
provenance: false
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
needs: [ pre-build ]
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID_TEST }}
TARGET: test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run git hooks
uses: devcontainers/ci@v0.2
env:
GOOGLE_APPLICATION_CREDENTIALS: /var/secrets/google/client_secrets.json
with:
cacheFrom: ${{ env.IMAGE_NAME }}:${{ env.DATASET }}.gh-${{ github.run_id }}.${{ github.run_attempt }}
runCmd: |
pre-commit run
- name: Run test
uses: devcontainers/ci@v0.2
env:
GOOGLE_APPLICATION_CREDENTIALS: /var/secrets/google/client_secrets.json
with:
cacheFrom: ${{ env.IMAGE_NAME }}:${{ env.DATASET }}.gh-${{ github.run_id }}.${{ github.run_attempt }}
runCmd: |
dbt test -m state:modified+ --defer --state .
```
The first devcontainer call:

The second devcontainer call:

it doesn't look like in the first instance of devcontainer the cache is being used?
The build and push step is successful:

Beitragsleitfaden
Rechercherichtung
Beginne mit dem Schritt docker/build-push-action des pre-build-Jobs und vergleiche dessen cache-from/cache-to-Einstellungen mit dem an devcontainers/ci@v0.2 übergebenen Wert cacheFrom. Untersuche die Logs beider devcontainer-Aufrufe und überprüfe, dass der erste Aufruf das gepushte Image oder den Cache wiederverwendet, anstatt es neu zu erstellen; als erledigt gilt dies, wenn der konfigurierte Cache konsistent verwendet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- docker, github-actions
- Bereich
- ci-cd, devops
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100