Hi Simen Daehlin, Thanks for the wonderful article. It helps me a lot in setting up development environment on docker suing Strapi v4.
I was facing this error when using this Dockerfile to start starpi:
tw-backend | yarn run v1.22.19
tw-backend | $ strapi develop
tw-backend | Starting the compilation for TypeScript files in /opt/app
tw-backend | [2022-09-15 06:19:31.420] debug: ⛔️ Server wasn't able to start properly.
tw-backend | [2022-09-15 06:19:31.423] error: Could not load js config file /opt/app/node_modules/@strapi/plugin-upload/strapi-server.js:
tw-backend | Something went wrong installing the "sharp" module
tw-backend |
tw-backend | Cannot find module '../build/Release/sharp-linuxmusl-x64.node'
So, I solved this issue by by doing these two changes, move node_modules into opt/app and add install sharp
Adding my Dockerfile to save time for those who are facing the same issue
FROM node:16-alpine
# Installing libvips-dev for sharp Compatability
RUN apk update && apk add build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/app
COPY ./package.json ./yarn.lock ./
# ENV PATH /opt/node_modules/.bin:$PATH
RUN yarn config set network-timeout 600000 -g && yarn install
RUN yarn add --verbose --platform=linuxmusl --arch=x64 sharp
# WORKDIR /opt/app
COPY ./ .
RUN yarn build
EXPOSE 1337
CMD ["yarn", "develop"]