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

Unable to build the production Docker image due to sharp installation issues. #20228

Closed
lgt opened this issue Apr 29, 2024 · 1 comment
Closed
Labels
flag: question Automation Flag to handle community questions

Comments

@lgt
Copy link

lgt commented Apr 29, 2024

Bug report

Required System information

  • Node.js version: node:20-alpine
  • NPM version:
  • Strapi version: 4.24.0
  • Database: mysql
  • Operating system: Raspian ARM
  • Is your project Javascript or Typescript: yes

Describe the bug

Using the provided example in the documentation to build dockerized production images, the image will fail to start with the following error.

2024-04-29 19:28:50 yarn run v1.22.19
2024-04-29 19:28:50 $ strapi start
2024-04-29 19:28:51 [2024-04-29 17:28:51.522] debug: ⛔️ Server wasn't able to start properly.
2024-04-29 19:28:51 [2024-04-29 17:28:51.523] error: Could not load js config file /opt/node_modules/@strapi/plugin-upload/strapi-server.js: 
2024-04-29 19:28:51 Something went wrong installing the "sharp" module
2024-04-29 19:28:51 
2024-04-29 19:28:51 Cannot find module '../build/Release/sharp-linuxmusl-arm64v8.node'

here bellow my Dockerfile.prod


# Creating multi-stage build for production
FROM node:20-alpine as build
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1
ENV NODE_ENV=production

WORKDIR /opt/
COPY package.json yarn.lock ./
RUN yarn global add node-gyp
RUN yarn config set network-timeout 600000 -g && yarn install --production --ignore-scripts
ENV PATH /opt/node_modules/.bin:$PATH
WORKDIR /opt/app
COPY . .
RUN yarn build

# Creating final production image
FROM node:20-alpine
RUN apk add --no-cache vips-dev
ENV NODE_ENV=production
WORKDIR /opt/
COPY --from=build /opt/node_modules ./node_modules
WORKDIR /opt/app
COPY --from=build /opt/app ./
ENV PATH /opt/node_modules/.bin:$PATH

RUN chown -R node:node /opt/app
USER node
EXPOSE 1337
CMD ["yarn", "start"]

Steps to reproduce the behavior

To reproduce the error on a macOS M1, I build the image locally, which will result in the same error upon startup.

@derrickmehaffy derrickmehaffy added the flag: question Automation Flag to handle community questions label Apr 29, 2024
Copy link
Contributor

This is a templated message

Hello @lgt,

I see you are wanting to ask a question that is not really a bug report,

Please see the following contributing guidelines for asking a question here.

Thank you.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: question Automation Flag to handle community questions
Projects
Status: Done
Development

No branches or pull requests

2 participants