skip to Main Content

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

6

Answers


  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
    
    Login or Signup to reply.
  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
    
    Login or Signup to reply.
  3. 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
    ...
    
    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. For me this only worked

    Changing

    FROM node:14-alpine
    

    to

    FROM node:14
    
    Login or Signup to reply.
  6. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search