MD. Jahidul Islam
MD. Jahidul Islam

Reputation: 655

python version causing problem during Docker build

I would like to avoid the following error. what should be the right way to do that. I could try to fix it by using python2-2.7.18-r0 instead of 2.7.16-r3. But the question is: will it be the future proof?

ERROR: unsatisfiable constraints:
  python2-2.7.18-r0:
    breaks: world[python=2.7.16-r3]
ERROR: Service 'frontend' failed to build: The command '/bin/sh -c apk add --no-cache make==4.2.1-r2 python=2.7.16-r3 g++=9.2.0-r4' returned a non-zero code: 1

Here is my Dockerfile:

FROM node:current-alpine as app-builder
ARG NODE_ENV
ENV NODE_ENV ${NODE_ENV}

RUN apk add --no-cache make==4.2.1-r2 python=2.7.16-r3 g++=9.2.0-r4
RUN mkdir -p /app
WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

COPY . .
RUN yarn build

Upvotes: 1

Views: 626

Answers (1)

David Maze
David Maze

Reputation: 158908

Will it be future proof?

No. Python 2 is already end-of-lifed. It will not get any bug fixes and security issues will not be addressed. You should upgrade your application to Python 3, ideally before the Python 2 end-of-life date of 1 January 2020 (four months ago).

In terms of the Dockerfile you show, I'd avoid extremely specific version constraints like you have. Using the latest version of packages in a specific release of a Linux distribution is usually safe (code tested on Python 2.7.16-r3 will almost certainly run fine on Python 2.7.18-r0). You might want to pick a more specific distribution in your image's FROM line (for example, FROM node:14-alpine3.11) to minimize surprises.

Upvotes: 1

Related Questions