Skip to content

Commit 093b206

Browse files
committed
Speed up Docker chown via COPY parameter
For some reason running the `chown` command explicitly is hanging on Docker. Using the `--chown` parameter in the `COPY` command is faster. However that new method has a couple of drawbacks: 1) it was introduced in a recent Docker version 17+ 2) it doesn't accept variables as argument, only hardcoded values Unfortunately we still need to use explicit "shell" `chown` for the `ANDROID_SDK_HOME` as this directory must still be writable. Error was: ``` A problem occurred configuring root project 'bdisttest_python2'. > Failed to install the following SDK components: build-tools;27.0.3 Android SDK Build-Tools 27.0.3 The SDK directory is not writable (/opt/android/android-sdk) ```
1 parent b168978 commit 093b206

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Dockerfile.py2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
119119
RUN pip install --upgrade cython==0.28.6
120120

121121
WORKDIR ${WORK_DIR}
122-
COPY . ${WORK_DIR}
123-
124-
# user needs ownership/write access to these directories
125-
RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME}
122+
COPY --chown=user:user . ${WORK_DIR}
123+
RUN chown --recursive ${USER} ${ANDROID_SDK_HOME}
126124
USER ${USER}
127125

128126
# install python-for-android from current branch

Dockerfile.py3

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
119119
RUN pip3 install --upgrade cython==0.28.6
120120

121121
WORKDIR ${WORK_DIR}
122-
COPY . ${WORK_DIR}
123-
124-
# user needs ownership/write access to these directories
125-
RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME}
122+
COPY --chown=user:user . ${WORK_DIR}
123+
RUN chown --recursive ${USER} ${ANDROID_SDK_HOME}
126124
USER ${USER}
127125

128126
# install python-for-android from current branch

0 commit comments

Comments
 (0)