I got it working with the following dockerfile: ```
Creating multi-stage build for production
FROM node:20-alpine as build
RUN apk add --no-cache build-base gcc autoconf automake libpng-dev vips-dev git g++
&& export CXX=g++
&& export CC=gcc
&& export CXXFLAGS=“-std=c++11”
&& export CFLAGS=“-std=c++11”
ENV NODE_ENV=${NODE_ENV}
ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1
WORKDIR /opt/
COPY package.json yarn.lock ./
RUN yarn global add node-gyp
RUN yarn install --production --ignore-scripts --network-timeout 600000 && yarn add sharp
RUN yarn cache clean
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”]
I guess this would only apply if your building for ARM then 
I also think RUN npm install --arch=arm64 --platform=linuxmusl sharp
could be used to force a sharp install for ARM but have to test it
Ahhh ok yeah then you would need to build sharp from source in alpine as it doesn’t have everything built in for ARG so what was posted above should work 
You can also change the OS of the container, xD
I build the images locally with docker buildx build --build-arg NODE_ENV=production --platform linux/arm64/v8 --tag namespace/strap:${change_it} --no-cache -f Dockerfile.prod .
and I have a github-action which is doing the same. Here is the job - name: Build & push image uses: docker/build-push-action@v5 with: context: . push: true cache-from: type=gha cache-to: type=gha,mode=max tags: ${{ env.IMAGE_REPOSITORY }}:latest, ${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }} build-args: | NODE_ENV=production platforms: linux/arm64 file: ./Dockerfile.prod provenance: false
make sure your docker builder is running in ARM. Like the comment above. It then builds Sharp in a ARM env.
I’m building linux/amd images from a Mac M2 using node:20-slim
without issue. Note that it is not an alpine image
Seems it’s alpine specific then, could we maybe narrow down if it’s a specific version of alpine. Though the update that <@1234565735922012251> i’m going to test myself too, seems it’s just setting the flags and ignoring global sharp etc. But will give it a quick test.
I’ve encountered too many edge cases with alpine based images over the years to use them much anymore. I’m more worried about reliability and consistency than a few MB
shouldn’t you use node 18 for Strapi by the way?
actually does not makes any difference, tried. I you take a look in package.json it is not restricted "engines": { "node": ">=18.0.0 <=20.x.x", "npm": ">=6.0.0" },
I tried a number of node version, it was switching from alpine to debian-slim that fixed it reliably
I may make a Dagger Function that makes this a one-liner for everyone
dagger -m github.com/verdverm/daggerverse/strapi@v.0.1.2 call build
or something like that
I am using a similair docker setup and it works just fine. On ARM locally (m2) and used to run ubuntu amd servers, now arm servers. no problems.