Skip to content

Commit

Permalink
Speed up Docker chown via COPY parameter
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
AndreMiras committed Feb 1, 2019
1 parent b168978 commit 093b206
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Dockerfile.py2
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN pip install --upgrade cython==0.28.6

WORKDIR ${WORK_DIR}
COPY . ${WORK_DIR}

# user needs ownership/write access to these directories
RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME}
COPY --chown=user:user . ${WORK_DIR}
RUN chown --recursive ${USER} ${ANDROID_SDK_HOME}
USER ${USER}

# install python-for-android from current branch
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile.py3
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN pip3 install --upgrade cython==0.28.6

WORKDIR ${WORK_DIR}
COPY . ${WORK_DIR}

# user needs ownership/write access to these directories
RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME}
COPY --chown=user:user . ${WORK_DIR}
RUN chown --recursive ${USER} ${ANDROID_SDK_HOME}
USER ${USER}

# install python-for-android from current branch
Expand Down

0 comments on commit 093b206

Please sign in to comment.