Skip to content

Commit 21e78d2

Browse files
committed
prevent long delay running chown when building docker image
1 parent 11fa372 commit 21e78d2

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

connector-definition/Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ COPY requirements.txt /functions/
44

55
WORKDIR /functions
66

7-
RUN python3 -m venv venv && \
8-
. venv/bin/activate && \
9-
pip install -r requirements.txt
10-
11-
COPY ./ /functions
12-
137
# create the group and user
148
RUN adduser -u 1000 python
159

1610
RUN chown -R python:python /functions
1711

18-
# stating USER before WORKDIR means the directory is created with the non-root proper ownership
19-
USER python
12+
# Switch to python user before activating venv - the alternative is to run chown on installed
13+
# dependencies afterward, which takes a long time.
14+
USER python
15+
16+
RUN python3 -m venv venv && \
17+
. venv/bin/activate && \
18+
pip install --upgrade pip>=25.3 && \
19+
pip install -r requirements.txt
20+
21+
COPY --chown=python:python ./ /functions

0 commit comments

Comments
 (0)