strapi-docker: npm run build fails when using in a docker container
Strapi version: 3.0.0-beta.6 Node: 12
Locally works ok, but inside a docker container, it cannot build an admin panel.
Dockerfile contents:
FROM node:11.5.0-alpine
COPY . /var/www/cms
WORKDIR /var/www/cms
RUN apk add --no-cache \
autoconf \
automake \
gcc \
libc-dev \
libtool \
make \
nasm \
zlib-dev \
&& chmod +x ./strapi.sh
RUN npm install
EXPOSE 1337
CMD ["./strapi.sh"]
strapi.sh contents:
#!/bin/sh
set -ea
_stopStrapi() {
echo "Stopping strapi"
kill -SIGINT "$strapiPID"
wait "$strapiPID"
}
trap _stopStrapi SIGTERM SIGINT
cd /var/www/cms
APP_NAME=${APP_NAME}
DATABASE_HOST=${DATABASE_HOST}
DATABASE_PORT=${DATABASE_PORT}
DATABASE_NAME=${DATABASE_NAME}
DATABASE_USERNAME=${DATABASE_USERNAME}
DATABASE_PASSWORD=${DATABASE_PASSWORD}
NODE_ENV=production npm run build
NODE_ENV=production npm run start &
strapiPID=$!
wait "$strapiPID"
On the step - NODE_ENV=production npm run build - it’s failing with following errors:
cms | Building your admin UI with production configuration ...
cms | ℹ Compiling Webpack
cms | (node:17) UnhandledPromiseRejectionWarning: Error: spawn Unknown system error -8
cms | at ChildProcess.spawn (internal/child_process.js:372:11)
cms | at Object.spawn (child_process.js:543:9)
cms | at module.exports (/var/www/cms/node_modules/imagemin-pngquant/node_modules/execa/index.js:204:26)
cms | at input (/var/www/cms/node_modules/imagemin-pngquant/index.js:52:13)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 39 (5 by maintainers)
I just had this issue running
strapi/strapi:latestwith docker-compose, following this guideline, but usingmysqlinstead of Mongo DB: https://strapi.io/blog/how-to-run-a-strapi-dev-stack-with-docker-composeThe container won’t stay up, so I cannot bash into it and run
npm installmanually.HI,
We just released a full rebuild of our docker image 🎉 We are closing the issues and open PRs to start fresh.
If you feel like something is missing or want to add things feel free to open new PRs ! 💯
@alexandrebodin I just got a build that failed for the first time with issue
edit Nevermind, I think it was a matter of me trying to use /srv/app for my custom image but it looks like it conflicts with the Base image.
Just found: https://github.com/strapi/strapi/issues/3383, it’s related to ram i guess. Node-sass eats too much ram. I just got the same
npm ERR! Exit status 137, sometimes it builds, sometimes - not. Going to try to increase RAM. Node version doesn’t matter actually.It worked for me. thanks 😉
I just released a new version of the image that fixing an error with the node_modules not being installed if the project doesn’t have a package-lock or yarn.lock file. can you test this @rogoit ?
@alexandrebodin I am sorry to say this but it is a lame strategy to close an unsolved issue just because there’s a rebuild of the images. It seems like people are still having the same issues that was first reported a year back. So, it is evident that “rebuilding” images didn’t fix anything.
It’s kinda working, i’ll try to remove container and build up again, to exclude randomness.