From dd9f6ad2dea18dc1b50c1434a829445529191f19 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sat, 3 Feb 2024 09:47:08 -0800 Subject: [PATCH 1/6] Bump alpine version used in Dockerfile Brings us to latest alpine, and to a newer python --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0cffcd18..94e3eced 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax = docker/dockerfile:1.3 -ARG ALPINE_VERSION=3.17 +ARG ALPINE_VERSION=3.19 FROM alpine:${ALPINE_VERSION} RUN apk add --no-cache git python3 python3-dev py3-pip py3-setuptools build-base From 756e7d1a983958840f3226d507254c2fe0855a12 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sat, 3 Feb 2024 09:52:29 -0800 Subject: [PATCH 2/6] Put everything inside a venv --- Dockerfile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94e3eced..277cbbde 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,12 +5,17 @@ FROM alpine:${ALPINE_VERSION} RUN apk add --no-cache git python3 python3-dev py3-pip py3-setuptools build-base # build wheels in first image +ENV VIRTUAL_ENV /opt/venv +ENV PATH ${VIRTUAL_ENV}/bin:${PATH} + +RUN python3 -m venv ${VIRTUAL_ENV} + ADD . /tmp/src RUN cd /tmp/src && git clean -xfd && git status RUN mkdir /tmp/wheelhouse \ && cd /tmp/wheelhouse \ - && pip3 install wheel \ - && pip3 wheel --no-cache-dir /tmp/src \ + && pip install wheel \ + && pip wheel --no-cache-dir /tmp/src \ && ls -l /tmp/wheelhouse FROM alpine:${ALPINE_VERSION} @@ -18,13 +23,18 @@ FROM alpine:${ALPINE_VERSION} # install python, git, bash, mercurial RUN apk add --no-cache git git-lfs python3 py3-pip py3-setuptools bash docker mercurial +ENV VIRTUAL_ENV /opt/venv +ENV PATH ${VIRTUAL_ENV}/bin:${PATH} + +RUN python3 -m venv ${VIRTUAL_ENV} + # install hg-evolve (Mercurial extensions) -RUN pip3 install hg-evolve --user --no-cache-dir +RUN pip install hg-evolve --user --no-cache-dir # install repo2docker COPY --from=0 /tmp/wheelhouse /tmp/wheelhouse -RUN pip3 install --no-cache-dir --ignore-installed --no-deps /tmp/wheelhouse/*.whl \ - && pip3 list +RUN pip install --no-cache-dir --ignore-installed --no-deps /tmp/wheelhouse/*.whl \ + && pip list # add git-credential helper COPY ./docker/git-credential-env /usr/local/bin/git-credential-env From 601fa252911ddea0fc4eccf2c57bbffdb00355f8 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sat, 3 Feb 2024 09:59:02 -0800 Subject: [PATCH 3/6] Don't use --user to install anything --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 277cbbde..6579c0c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ENV PATH ${VIRTUAL_ENV}/bin:${PATH} RUN python3 -m venv ${VIRTUAL_ENV} # install hg-evolve (Mercurial extensions) -RUN pip install hg-evolve --user --no-cache-dir +RUN pip install hg-evolve --no-cache-dir # install repo2docker COPY --from=0 /tmp/wheelhouse /tmp/wheelhouse From 57e4b3f687965eb1c07068988afca8ed6134b303 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 24 Mar 2024 22:18:23 +0100 Subject: [PATCH 4/6] Fix unrelated comment --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6579c0c5..44a38a3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM alpine:${ALPINE_VERSION} RUN apk add --no-cache git python3 python3-dev py3-pip py3-setuptools build-base -# build wheels in first image +# build wheels in a build stage ENV VIRTUAL_ENV /opt/venv ENV PATH ${VIRTUAL_ENV}/bin:${PATH} From f121a0d481d937c09b48b5965abe00387f5cf2ed Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 24 Mar 2024 22:22:47 +0100 Subject: [PATCH 5/6] Use modern ENV syntax in Dockerfile The use of `ENV key value` is an old alternative syntax still around for backward compatibility, but may be removed according to https://docs.docker.com/reference/dockerfile/#env. --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 44a38a3e..93a98123 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ FROM alpine:${ALPINE_VERSION} RUN apk add --no-cache git python3 python3-dev py3-pip py3-setuptools build-base # build wheels in a build stage -ENV VIRTUAL_ENV /opt/venv -ENV PATH ${VIRTUAL_ENV}/bin:${PATH} +ENV VIRTUAL_ENV=/opt/venv +ENV PATH=${VIRTUAL_ENV}/bin:${PATH} RUN python3 -m venv ${VIRTUAL_ENV} @@ -23,8 +23,8 @@ FROM alpine:${ALPINE_VERSION} # install python, git, bash, mercurial RUN apk add --no-cache git git-lfs python3 py3-pip py3-setuptools bash docker mercurial -ENV VIRTUAL_ENV /opt/venv -ENV PATH ${VIRTUAL_ENV}/bin:${PATH} +ENV VIRTUAL_ENV=/opt/venv +ENV PATH=${VIRTUAL_ENV}/bin:${PATH} RUN python3 -m venv ${VIRTUAL_ENV} From 91d3f150e5b5cfe7e959413bedeacee11b83f4aa Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 24 Mar 2024 22:35:15 +0100 Subject: [PATCH 6/6] Use ARG instead of ENV for build time only environment variable --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 93a98123..74fbad89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM alpine:${ALPINE_VERSION} RUN apk add --no-cache git python3 python3-dev py3-pip py3-setuptools build-base # build wheels in a build stage -ENV VIRTUAL_ENV=/opt/venv +ARG VIRTUAL_ENV=/opt/venv ENV PATH=${VIRTUAL_ENV}/bin:${PATH} RUN python3 -m venv ${VIRTUAL_ENV} @@ -23,7 +23,7 @@ FROM alpine:${ALPINE_VERSION} # install python, git, bash, mercurial RUN apk add --no-cache git git-lfs python3 py3-pip py3-setuptools bash docker mercurial -ENV VIRTUAL_ENV=/opt/venv +ARG VIRTUAL_ENV=/opt/venv ENV PATH=${VIRTUAL_ENV}/bin:${PATH} RUN python3 -m venv ${VIRTUAL_ENV}