question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

use cache of non container job in container job

See original GitHub issue

I cant use the created cache inside a container job, if the cache was created in an non container job.

The error is see in the container job “js-jest” is:

/usr/bin/docker exec  d681d1c1d1bcf898d5a7572538c549201c3d35aa22e366f14085ed1681753d31 sh -c "cat /etc/*release | grep ^ID"
Cache not found for input keys: Linux-node--d427a8aabcc0acf518e5cf6e5e4f3541ac6d9d8b4d3d10b1e26d8704b65748f7, Linux-node-

The non container “prettier” job uses the cache and works. Even if its not realy used here i’ve added an “ls -al” to the run part so i could see, that the cache was there.

This is the whole workflow config:

name: ci

on:
  pull_request:

jobs:
  install-npm:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '10.19'
      - uses: actions/cache@v2
        id: cache-npm
        with:
          path: |
            .env
            .npm
            node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: ${{ runner.os }}-node-
      - name: run npm
        if: steps.cache-npm.outputs.cache-hit != 'true'
        run: |
          make
          npm ci --no-progress


  js-jest:
    container:
      image: specialpurposecontainer:latest
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GHCR_TOKEN }}
    needs: install-npm
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '10.19'
      - uses: actions/cache@v2
        id: cache-npm
        with:
          path: |
            .env
            .npm
            node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: ${{ runner.os }}-node-
      - name: run npm
        run: npm run test:ci


  prettier:
    needs: install-npm
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '10.19'
      - uses: actions/cache@v2
        id: cache-npm
        with:
          path: |
            .env
            .npm
            node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: ${{ runner.os }}-node-
      - name: run npm
        run: npm run prettier

If there is some special config needed to use the cache inside the container, i would be glad if somebody could share it.

What seems to be a workaround is to run all jobs in containers but that makes ci slower.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
dhadkacommented, Feb 2, 2021

Thanks! Yes, as I expected the container is unable to find zstd:

2021-02-02T17:05:14.4289972Z ##[debug]Checking zstd --version
2021-02-02T17:05:14.4325677Z ##[debug]Unable to locate executable file: zstd. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2021-02-02T17:05:14.4327267Z ##[debug]

Any chance you can create the container image with zstd?

2reactions
jderroughcommented, Sep 6, 2021

Not sure why building on top of a node image didn’t work but I managed to build on top of ubuntu:

# syntax=docker/dockerfile:1
FROM ubuntu:latest
ARG NODE_VERSION=current
RUN apt-get update
RUN apt-get install -y curl sudo zstd
RUN curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | sudo bash -
RUN apt-get install -y nodejs
RUN npm install -g yarn

The Dockerfile can be found here: https://github.com/jderrough/node-zstd You can get the images here: https://hub.docker.com/repository/docker/jderrough/node-zstd And refence them like so:

container: jderrough/node-zstd:ubuntu-node14
Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure DevOps Container Jobs: Cache Container for multiple ...
So has anyone solved caching the container? Here is an example: # in this example, all jobs use the same container. # in...
Read more >
Define container jobs (YAML) - Azure Pipelines - Microsoft Learn
The container job uses the underlying host agent Docker config.json for image registry authorization, which logs out at the end of the Docker ......
Read more >
Cache key file paths incorrectly presented in container jobs
File paths shown in the log for the Cache/CacheBeta task are incorrectly shown in their "host path" form when running in a container...
Read more >
Working with OneDev Cache - Medium
Working with OneDev Cache ... CI/CD jobs running in a container always starts with a clean environment, and can be slow as it...
Read more >
Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. Subsequent jobs that use the same cache don't have to download...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found