This is because alpine recently moved the vips-dev package from edge/testing to edge/community. See this issue for some context on the sharp repo: github.com/lovell/sharp/issues/1733
To fix it, just change the repo URL in the post above from: http://dl-3.alpinelinux.org/alpine/edge/testing to http://dl-3.alpinelinux.org/alpine/edge/community.
Also, I had to change the --no-cache in the second apk command to --update-cache as is suggested in one of the referenced PRs off the above issue. So, your full docker RUN command for APK installs would look like this (formatting changed):
Hope that helps someone else. It had me stuck for a while. :-P
In addition, yarn fails for me with the latest node (for alpine or otherwise). So, I also had to change the FROM line to fix it to the latest v8. E.g.,
FYI: At the time of writing, Edge was the only option for this... and I really don't have time to keep this updated. Thanks for the heads up, I'll make another note at the top!
FROM node:12.18.2-alpine3.12# Install PM2 globallyRUN npm install--global pm2
#Install Gatsby CLIRUN npm install-g gatsby-cli
RUN mkdir /app
WORKDIR /appRUN chmod-R 777 /app
# Add node_modules to the pathENV PATH /app/node_modules/.bin:$PATH# Installing dependenciesCOPY package*.json /app/RUN cd /app/
RUN npm installCOPY . /app/# Building appRUN npm run build
# Run container as non-root (unprivileged) user# The node user is provided in the Node.js Alpine base imageUSER nodeEXPOSE 8000# Run npm start script with PM2 when container startsCMD [ "pm2-runtime", "npm", "--", "serve" ]
Would this actually be necessary for use in a local development setup like this? This is definitely not being used for production, by any stretch of imagination.
It's hard to say, but it looks like you may not have the gatsby-transformer-remark plugin installed and configured?
Sidenote, possibly relevant: If you add any new packages to your app, you will need to rebuild your image using docker-compose build (or docker-compose up --build)
Step 4/9 : RUN npm install -g gatsby-cli yarn
---> Running in bbc35321dd10
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/usr/local/bin/gatsby -> /usr/local/lib/node_modules/gatsby-cli/lib/index.js
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /usr/local/bin/yarn
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/local/bin/yarn'
npm ERR! File exists: /usr/local/bin/yarn
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-02-11T15_31_08_467Z-debug.log
ERROR: Service 'web' failed to build: The command '/bin/sh -c npm install -g gatsby-cli yarn' returned a non-zero code: 239
Thanks for the message. It looks like they are now including Yarn with the lastest versions of Alpine:Node, and it's throwing an error trying to re-install it. I'll get it corrected in just a moment or two. 💜
I just copy-pasted all two files , run docker-compose -up build
and got the error:
Step 6/9 : COPY ./package.json .
ERROR: Service 'web' failed to build: COPY failed: stat /var/snap/docker/common/var-lib-docker/tmp/docker-builder603792599/package.json: no such file or directory
No prob, Nick! Yeah, the code highlighting on this site isn't very visible, I know... you'll want to run: docker-compose up (from your project's root directory) :)
Just a note for anyone else that reads this and runs into this error:
This is because alpine recently moved the vips-dev package from
edge/testingtoedge/community. See this issue for some context on thesharprepo: github.com/lovell/sharp/issues/1733To fix it, just change the repo URL in the post above from:
http://dl-3.alpinelinux.org/alpine/edge/testingtohttp://dl-3.alpinelinux.org/alpine/edge/community.Also, I had to change the
--no-cachein the second apk command to--update-cacheas is suggested in one of the referenced PRs off the above issue. So, your full dockerRUNcommand for APK installs would look like this (formatting changed):Hope that helps someone else. It had me stuck for a while. :-P
In addition, yarn fails for me with the latest node (for alpine or otherwise). So, I also had to change the
FROMline to fix it to the latest v8. E.g.,This doesn't work anymore. Also don't use edge, always pin down a stable version.
See more here: gitlab.alpinelinux.org/alpine/apor...
Change to version 3.10.
FYI: At the time of writing, Edge was the only option for this... and I really don't have time to keep this updated. Thanks for the heads up, I'll make another note at the top!
Here does not Work! Need to change python to python3. E.g.:
Awesome! Thanks for your super helpful comment, Jonathan! I'll be sure to make a note in the original post to see your comment.
Thanks for this :D
Hi, Here the configuration that worked for me.
Then "serve" in package.json goes like this .
Hey Ernesto et all thanks for sharing,
When trying to run this i get stuck with the following error
"Recreating frontend_web_1 ... done
Attaching to frontend_web_1
web_1 | 2020-11-14T02:58:15: PM2 log: Launching in no daemon mode
web_1 | 2020-11-14T02:58:15: PM2 log: App [npm:0] starting in -fork mode-
web_1 | 2020-11-14T02:58:15: PM2 log: App [npm:0] online
web_1 | Usage: npm
web_1 | where is one of:"
that repeats itself until i get
"web_1 | 2020-11-14T02:58:24: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
web_1 | 2020-11-14T02:58:24: PM2 log: Script /usr/local/bin/npm had too many unstable restarts (16). Stopped. "errored"
web_1 | 2020-11-14T02:58:25: PM2 log: 0 application online, retry = 3
web_1 | 2020-11-14T02:58:27: PM2 log: 0 application online, retry = 2
web_1 | 2020-11-14T02:58:29: PM2 log: 0 application online, retry = 1
web_1 | 2020-11-14T02:58:31: PM2 log: 0 application online, retry = 0
web_1 | 2020-11-14T02:58:31: PM2 log: Stopping app:npm id:0
web_1 | 2020-11-14T02:58:31: PM2 error: app=npm id=0 does not have a pid
web_1 | 2020-11-14T02:58:31: PM2 log: PM2 successfully stopped"
Any ideas?
Many thanks
Very nice, thanks for putting this together, Daniel! One thing I really do encourage you is to define a
USER, see also Node/Docker best practices and for the background canihaznonprivilegedcontainers.info.Hi Michael, thanks for the comment!
Would this actually be necessary for use in a local development setup like this? This is definitely not being used for production, by any stretch of imagination.
Thanks for sharing.
I have tried in ubuntu host and encountered this error.
It's hard to say, but it looks like you may not have the
gatsby-transformer-remarkplugin installed and configured?Sidenote, possibly relevant: If you add any new packages to your app, you will need to rebuild your image using
docker-compose build(ordocker-compose up --build)Thanks for your reply. It is weired. There is no problem when I run
docker-compose upin alpine linux host on VPS. Thanks anyway!Not working for me
Hey Konstantin!
Thanks for the message. It looks like they are now including Yarn with the lastest versions of Alpine:Node, and it's throwing an error trying to re-install it. I'll get it corrected in just a moment or two. 💜
Thank you
How you resolve this error?
How you resolve this error?
Hi Daniel!
Thanks for sharing!
I just copy-pasted all two files , run docker-compose -up build
and got the error:
Step 6/9 : COPY ./package.json .
ERROR: Service 'web' failed to build: COPY failed: stat /var/snap/docker/common/var-lib-docker/tmp/docker-builder603792599/package.json: no such file or directory
After this message installation stopped.
May be you have an idea how to fix?
Based on that error, it looks like there was no
package.jsonfile found.Do you have the
Dockerfileanddocker-compose.ymlfiles in the root of your Gatsby project directory?Great post, thanks.
What's the command to run it?
No prob, Nick! Yeah, the code highlighting on this site isn't very visible, I know... you'll want to run:
docker-compose up(from your project's root directory) :)So can i use vscode to code in gatsby without installing gastby globally on my local machine?
How will you setup your docker for production deployment with continuous build when the user add new post in wordpress ?