I am developing my app in a Docker environment to mirror the production environment as closely as possible. Therefore, the build speed is important to have a high iteration speed. The command that takes the longest after making iterative changes (not changing Python dependencies) in my build script is
RUN chown -R flask:flaskgroup /home/flask
Is there a way around this, so that the COPY . /home/flask/app/web
already sets the files with the correct permissions. Tangential question, is there a way to measure the time each step requires to have a quantitative metric (other than a perceived time)?
As a reference, the complete script:
FROM python:3.5.2 MAINTAINER Moritz Ulmer <moritz.ulmer@posteo.de> # Create the group and user to be used in this container RUN groupadd flaskgroup && useradd -m -g flaskgroup -s /bin/bash flask # Create the working directory (and set it as the working directory) RUN mkdir -p /home/flask/app/web WORKDIR /home/flask/app/web # Install the package dependencies (this step is separated # from copying all the source code to avoid having to # re-install all python packages defined in requirements.txt # whenever any source code change is made) COPY requirements.txt /home/flask/app/web RUN pip install --no-cache-dir -r requirements.txt # Copy the source code into the container COPY . /home/flask/app/web RUN chown -R flask:flaskgroup /home/flask USER flask