1

I have this DockerFile

FROM docker:17.12.0-ce as static-docker-source

FROM ubuntu:18.04
FROM python:3.8-slim-buster

ARG CLOUD_SDK_VERSION=335.0.0
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH "$PATH:/opt/google-cloud-sdk/bin/"
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
RUN apt-get -qqy update && apt-get install -qqy \
    curl \
    gcc \
    apt-transport-https \
    lsb-release \
    openssh-client \
    git \
    gnupg && \
pip install crcmod && \
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && \
apt-get install -y google-cloud-sdk=${CLOUD_SDK_VERSION}-0 \
    google-cloud-sdk-app-engine-python=${CLOUD_SDK_VERSION}-0 \
    google-cloud-sdk-app-engine-python-extras=${CLOUD_SDK_VERSION}-0 \
    google-cloud-sdk-cbt=${CLOUD_SDK_VERSION}-0 \
    kubectl && \
gcloud --version && \
docker --version && kubectl version --client
VOLUME ["/root/.config"]

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN curl -sL https://sentry.io/get-cli/ | bash -

RUN apt-get install -y nodejs build-essential pkg-config libcairo2-dev libjpeg-dev libgif-dev

ADD requirements.txt /
ADD requirements-prod.txt /

ADD submodules /
RUN python --version
RUN pip3 install --upgrade pip

RUN pip3 install -r /requirements.txt
RUN pip3 install -r /requirements-prod.txt

when I run node --version it returns v10.24.0 (I think it should be 8.x.y ....). And when I run npm --version it returns bash: npm: command not found

Shouldn't node install npm too ?

Thanks

5
  • You're installing an old nodejs version: Commented Apr 14, 2021 at 20:57
  • RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - Commented Apr 14, 2021 at 20:57
  • Try using RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - Commented Apr 14, 2021 at 20:58
  • So actually, removing FROM python:3.8-slim-buster and adding python via apt without changing anything else seems to do the trick. I know this is an old version of python but this an old project and I do not want to upgrade it at risks of causing breaking change... Commented Apr 14, 2021 at 21:04
  • Glad you solved it like this, why not create an answer and mark it as accepted. Commented Apr 14, 2021 at 21:07

1 Answer 1

1

So I fixed it by changing my DockerFile.

I deleted FROM python:3.8-slim-buster as I read that having multiple 'FROM' on a dockerfile could cause conflict. And I installed python with apt like this:

RUN apt-get -qqy update && apt-get install -qqy \
    curl \
    gcc \
    python3.8 \
    python3-pip \
    python3.8-dev \

However, it is not perfect to me because I now have python3.6.x under python 3, python 2.7.x under python and I must specified python3.8 when I need it...


My new DockerFile:

FROM docker:17.12.0-ce as static-docker-source

FROM ubuntu:18.04

ARG CLOUD_SDK_VERSION=335.0.0
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH "$PATH:/opt/google-cloud-sdk/bin/"
COPY --from=static-docker-source /usr/local/bin/docker 
/usr/local/bin/docker
RUN apt-get -qqy update && apt-get install -qqy \
    curl \
    gcc \
    python3.8 \
    python3-pip \
    python3.8-dev \
    apt-transport-https \
    lsb-release \
    openssh-client \
    git \
    gnupg && \
pip3 install crcmod && \
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && \
apt-get install -y google-cloud-sdk=${CLOUD_SDK_VERSION}-0 \
    google-cloud-sdk-app-engine-python=${CLOUD_SDK_VERSION}-0 \
    google-cloud-sdk-app-engine-python-extras=${CLOUD_SDK_VERSION}-0 \
    google-cloud-sdk-cbt=${CLOUD_SDK_VERSION}-0 \
    kubectl && \
gcloud --version && \
docker --version && kubectl version --client
VOLUME ["/root/.config"]

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN curl -sL https://sentry.io/get-cli/ | bash -

RUN apt-get install -y nodejs build-essential pkg-config libcairo2-dev 
libjpeg-dev libgif-dev
RUN node --version
RUN npm --version
RUN python --version
ADD requirements.txt /
ADD requirements-prod.txt /

ADD submodules /
RUN python --version
RUN pip3 install --upgrade pip

RUN pip3 install -r /requirements.txt
RUN pip3 install -r /requirements-prod.txt
Sign up to request clarification or add additional context in comments.

1 Comment

Edit queue is full.. can you please edit your answer to be more descriptive like this? ``` So I fixed it by changing my DockerFile: 1. Removing FROM python:3.8-slim-buster 2. Adding python via apt without changing anything ```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.