5

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
ouflak
  • 2,458
  • 10
  • 44
  • 49
ShaSha
  • 589
  • 3
  • 9
  • 24

6 Answers6

9

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

Y H
  • 492
  • 5
  • 9
2

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
helvete
  • 2,455
  • 13
  • 33
  • 37
kralendorf
  • 21
  • 2
1

You need to install python as part of your build process. For more details how to install python check here

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY ./ .
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
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
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
jordanvrtanoski
  • 5,104
  • 1
  • 20
  • 29
  • same loop, check if the binary/library/package is missing, and if so add to the Dockerfile. If you ware not tracking the dependancies properly, you will need to repeat this cycle several times until you find all the things that you are missing. – jordanvrtanoski Mar 12 '21 at 13:46
  • I recently bought a MacBook m1, in Linux os docker file was ok and no problem. – ShaSha Mar 12 '21 at 14:04
  • M1 is ARM64, some libraries/packages are still not available for M1, but it's not the case with `node-gyp`, it's most probably a problem with installation of the C/C++ build environment. Add `apk add alpine-sdk` to the Dockerfile and check agin. – jordanvrtanoski Mar 12 '21 at 14:15
1

For me this only worked

Changing

FROM node:14-alpine

to

FROM node:14
arun-r
  • 3,104
  • 2
  • 22
  • 20
1

For me the solution of Y H helps to add --platform=linux/amd64 in the FROM statement.

But if you don't want to change your Dockerfile, you can also set DOCKER_DEFAULT_PLATFORM before building the docker image:

export DOCKER_DEFAULT_PLATFORM=linux/amd64

Matthias M
  • 12,906
  • 17
  • 87
  • 116
0

Well, you need python. And the already provided answers here will provide you with that and the minimalist might be looking for something like that.

Another option would be not to use the alpine version of node (which comes for good reasons with a minimized footprint). I've personally accepted the overhead of a bigger image in favor of saving time by not installing python. So my (potentially opinionated) solution would be to just replace

# build stage
FROM node:lts-alpine as build-stage
...

with

# build stage
FROM node:lts as build-stage
...
Stefan W
  • 7,386
  • 1
  • 5
  • 2