-
Notifications
You must be signed in to change notification settings - Fork 88
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 development image #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aslafy-z this is pretty neat! Sounds awesome to me. The only change that I'd do would be to make this available under the gatsbyjs/cli
namespace instead and have it running on a different pipeline triggered on every gatsby@x.x.x
tag coming from the gatsbyjs/gatsby repo.
@KyleAMathews your thoughts on this?
Despite changes above I've provided, this only allows for getting This appears to be due to using the edge repositories for I've recently got a Docker Image that actually builds and runs properly. I had success with this Dockerfile and removing the Dockerfile
entry.sh
Build: Maybe if I find some time to work on it a bit more I could make another PR. Just thought I'd share this as if you try building the current PR and using it now, I think you'll run into the problems I've been pointing out. |
I applied all the suggestions and dropped the alpine @cusspvz Let me know about the name convention! |
I did come across another issue many times when messing around with getting a working Docker image, I believe it also happened with the above config I shared here. When running something like
It was resolved by adding bindings.js. But that's something that wouldn't belong here. For some reason, even if the .node file for sharp was where it said it looked, it wasn't able to find it and threw those errors. |
TL;DR: I have been playing around with my docker image variant again. Mostly because I wanted to address the crashes I was getting with 2 kinds of errors. One was if you used the
Also:
Solved by adding The other issue was only triggered if you enabled
The npm install failed because of this:
So you can get that with I've built the image multiple times and cleared out the mounted volume to reinstall again many times. Quite often the npm install appears to go fine sometimes yet if you add a package later or I had removed
One other optimization that I think is relevant to make here, These both want a c compiler, pngquant does too I think, though it's error just states it failed and if I made sure to have
Output from trying gcc instead of g++ to compile c:
Full Dockerfile: # Use gatsby-cli instead of gatsby, roughly 150MB vs 15MB difference!
# Remove dev dependencies that aren't required anymore(not building vips-dev),
# if a user needs to build for specific package they should build a new docker image extending this one
# python2 is about 40MB and might be useful for packages needing node-gyp to build
# g++ is about 150MB, gcc 85MB
FROM node:10-alpine # 70MB
# Install dev dependencies (gcc 85MB, git 15MB)
RUN set -x \
&& apk add --no-cache \
gcc \
git \
make
# Install gatsby cli and cleanup (adds about 15MB)
ARG GATSBY_VERSION=^2.0.0
RUN set -x \
&& npm install --global gatsby-cli@${GATSBY_VERSION} \
--no-optional gatsby-cli@${GATSBY_VERSION} \
&& npm cache clean --force
# These let toFormat work for image format conversions with webp
# imagemin plugins support(part of gatsby-plugin-sharp) (adds about 5MB)
# lcms2-dev - jpeg and tiff support
# libpng-dev - png support
RUN set -x \
&& apk add --no-cache \
lcms2-dev \
libpng-dev
# mozjpeg support 46MB (also depends on libpng-dev)
RUN set -x \
&& apk add --no-cache \
autoconf \
automake \
libtool \
nasm
RUN mkdir -p /site
WORKDIR /site
VOLUME /site
EXPOSE 8000
COPY ./entry.sh /
RUN chmod +x /entry.sh
ENTRYPOINT ["/entry.sh"] EDIT: While looking into multi-stage build for mozjpeg, it seems that they've recently switched away from autoreconf and use cmake now, so the current npm package is a tad out of date. Thus the dependencies aren't so relevant anymore.. |
Closes #16 #11
node:10-alpine
Build with:
docker build -t gatsbyjs/cli -f Dockerfile.cli .
Works best with a volume:
User is specified to ensure it doesn't fucked up your files permission.
Supported commands:
develop
->gatsby develop
build
->gatsby build
serve
->gatsby serve
stage
->gatsby build && gatsby serve
These commands need to have wrappers because they don't support configuration of host and port via variables environments. Too bad :(
You can also use others commands of
gatsby
which does not need a wrapper (eg.:repl
,new
,info
).If a folder without
package.json
file is mounted on the/site
dir, it will be provisioned with https://github.com/gatsbyjs/gatsby-starter-default.