Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Macbook m1 node js docker image build failed

This is message: enter image description here

What's wrong? I should wait for the production docker?

This is docker config:

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY ./ .
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
RUN mkdir /app
COPY --from=build-stage /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
like image 229
ShaSha Avatar asked Aug 27 '26 14:08

ShaSha


2 Answers

Try running it with linux/amd64.

In your docker config change:

FROM node:lts-alpine as build-stage

to

FROM --platform=linux/amd64 node:lts-alpine as build-stage

like image 56
Y H Avatar answered Aug 30 '26 06:08

Y H


You need python with make and g++ to build your dependencies.

FROM node:14-alpine as frontbuild  
#RUN apk add --no-cache python2 make g++ WORKDIR /tmp

COPY ./front/package.json .

RUN apk add --update --no-cache python2 make gcc libsass g++

RUN npm install --no-optional  --only-production

COPY front /tmp

ARG VUE_APP_BASE_URL ENV VUE_APP_BASE_URL $VUE_APP_BASE_URL ENV NODE_ENV production

RUN npm run build
like image 29
kralendorf Avatar answered Aug 30 '26 06:08

kralendorf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!