Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache docker image #42

Closed
saul-data opened this issue Oct 2, 2020 · 8 comments
Closed

Cache docker image #42

saul-data opened this issue Oct 2, 2020 · 8 comments

Comments

@saul-data
Copy link

Is there a way to cache the docker image of this action so it doesn't have to build each time? It takes a long time to run and it runs upfront before the rest of the steps.

@phips28
Copy link
Owner

phips28 commented Oct 2, 2020

dont know if thats possible.

@saul-data
Copy link
Author

Lets cast a net: https://stackoverflow.com/questions/64174918/github-actions-docker-caching :)

@NoNameProvided
Copy link

Instead of caching, the action can be built as a JS action: https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action.

@TheQueenIsDead
Copy link

I forked this repo, created a DockerHub repository, and set up a demo repo to attempt to pull a published image instead of building per workflow execution.

Turns out, it's supported, but not very well documented! Investigative work can be found in the StackOverflow question, but for now, please see #115 for a solution :^)

@melody-universe
Copy link
Contributor

Instead of caching, the action can be built as a JS action: https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action.

I've created a fork that switches this action to a JavaScript action. Unfortunately, as indicated in this documentation, node_modules needs to be present in the repository. I've set up a separate job in the workflow for this repository to download and commit node_modules by force, but still keep them in .gitignore them while developing.

I would much rather use a bundler like webpack to bundle the assets of this project, but because it depends on actions-toolkit, which uses dynamic imports, the bundled file throws an exception.

@melody-universe
Copy link
Contributor

I was really dissatisfied with adding node_modules to the repository, so I created a separate branch in my fork that generates a bundled asset instead.

In order to get this working, I needed to remove actions-toolkit and hand-wrote the few pieces of it that this library was actually using. After doing that, it became apparent we might not even need those.

I might create yet another branch that doesn't even use the bundler; if we remove all of our dependencies (right now just execa for spawning a child process and Signale for pretty logging), we can just execute index.js directly.

@melody-universe
Copy link
Contributor

execa was admittedly a little more difficult to peel off, but I created my last branch (for today) to remove all runtime dependencies entirely, so that node_modules (or a bundled file) isn't even needed at runtime.

Sorry for the PR spam, I wasn't sure which (if any) of these would be preferable... they're sequential but we can squash the PR on whichever one you prefer (also if any).

@phips28
Copy link
Owner

phips28 commented Sep 22, 2021

merged. thanks to @melody-universe !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants