Multistage dockerfile skips parts/stages [Nodejs & Python]

58 Views Asked by At

I have a project which consists of a React website (frontend) and a python script on a flask server (backend). My folder structure looks like this:

. --backend --frontend --Dockerfile

The content of my multi-staged Dockerfile is:

FROM node:14-slim as frontend WORKDIR /app/frontend COPY frontend/package*.json ./ RUN npm install COPY frontend . RUN npm run build EXPOSE 3000 FROM python:3.9.5-slim-buster as backend WORKDIR /app/backend COPY backend . RUN pip install --no-cache-dir -r requirements.txt EXPOSE 5000 CMD ["python", "server.py"]

Now here's the weird part:

When I run docker build -t myname . to build the docker-image the first part (nodejs) of the Dockerfile won't be executed. It starts with python, which means the whole nodejs part is missing and nothing of that will be copied. And I get no error messages.

Now when I switch the stages in the Dockerfile to start with python and secondly with nodejs, both will be executed, but the container won't work.

Has anybody an idea why the first stage will not be executed? I'm at my wits end :/

I'm using a windows 10 machine with docker desktop to build my images/container.

Thanks in advance!

0

There are 0 best solutions below