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

Add gatsby-plugin-sharp support? #1

Closed
m-allanson opened this issue Feb 16, 2018 · 3 comments
Closed

Add gatsby-plugin-sharp support? #1

m-allanson opened this issue Feb 16, 2018 · 3 comments
Assignees

Comments

@m-allanson
Copy link

Hi @aripalo, this looks great!

I tried installing gatsby-plugin-sharp, but it fails because it doesn't have all the tools available to build sharp and / or its dependencies. Luckily there is an Alpine image that contains those dependencies already - see https://github.com/lovell/sharp/blob/master/docs/install.md#docker

For some background - I've recently been experimenting with Docker images for building a documentation tool for Gatsby, so you can see an example of building a Gatsby friendly container there. Sadly my image is the standard full-fat Node.js / Ubuntu image.

For reference, I ran docker run -it --rm -v $(pwd)/site:/site aripalo/gatsby-docker yarn add gatsby-plugin-sharp

And the error output was:

error /site/node_modules/sharp: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /site/node_modules/sharp
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:166:21)
gyp ERR! System Linux 4.9.60-linuxkit-aufs
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /site/node_modules/sharp
@aripalo
Copy link
Owner

aripalo commented Feb 16, 2018

Good catch! I haven't yet gotten myself so far as to use gatsby-plugin-sharp with this Docker setup, but that is something this should support of course!

Thanks for the links! Gonna look into those!

@aripalo
Copy link
Owner

aripalo commented Feb 16, 2018

So I finally got the gatsby-plugin-sharp to succesfully install. Had to add quite a lot of new dependencies.

I created a PR #2, which I will close after I've had time to do more testing and figure out if I can get rid of some dependencies (probably won't have time before sunday).

If you wish to test this feature, see the instructions within the PR.

@aripalo aripalo self-assigned this Feb 16, 2018
@m-allanson
Copy link
Author

Nice! I'll give it a spin in the next day or two.

I saw this article the other day. Section 5 talks about installing dependencies and building files in one layer, then creating a fresh layer and copying in only the built files. Which should result in a smaller final image.. maybe it's possible to do the same with sharp?

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

2 participants