From 21e78d2d46efa95e751c3cd557b846d2b4c2cc63 Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Thu, 8 Jan 2026 11:25:41 -0800 Subject: [PATCH] prevent long delay running chown when building docker image --- connector-definition/Dockerfile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/connector-definition/Dockerfile b/connector-definition/Dockerfile index d5c2f47..73c405f 100644 --- a/connector-definition/Dockerfile +++ b/connector-definition/Dockerfile @@ -4,16 +4,18 @@ COPY requirements.txt /functions/ WORKDIR /functions -RUN python3 -m venv venv && \ - . venv/bin/activate && \ - pip install -r requirements.txt - -COPY ./ /functions - # create the group and user RUN adduser -u 1000 python RUN chown -R python:python /functions -# stating USER before WORKDIR means the directory is created with the non-root proper ownership -USER python \ No newline at end of file +# Switch to python user before activating venv - the alternative is to run chown on installed +# dependencies afterward, which takes a long time. +USER python + +RUN python3 -m venv venv && \ + . venv/bin/activate && \ + pip install --upgrade pip>=25.3 && \ + pip install -r requirements.txt + +COPY --chown=python:python ./ /functions