From 449d324427202abdf141d32f37794fa256d20ab2 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Thu, 1 Aug 2019 16:06:15 -0700 Subject: [PATCH] Don't run `pip install -r requirements.txt` in the Dockerfile Instead, make it a suggested postCreateCommand. --- containers/python-3/.devcontainer/Dockerfile | 15 +++++++-------- .../python-3/.devcontainer/devcontainer.json | 2 +- containers/python-3/.devcontainer/noop.txt | 3 --- containers/python-3/README.md | 6 +++--- 4 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 containers/python-3/.devcontainer/noop.txt diff --git a/containers/python-3/.devcontainer/Dockerfile b/containers/python-3/.devcontainer/Dockerfile index ba6d22a290..6dd7da52a5 100644 --- a/containers/python-3/.devcontainer/Dockerfile +++ b/containers/python-3/.devcontainer/Dockerfile @@ -13,11 +13,10 @@ ARG USERNAME=vscode ARG USER_UID=1000 ARG USER_GID=$USER_UID -# Copy requirements.txt (if found) to a temp location so we can install it. The `*` -# is required so COPY doesn't think that part of the command should fail is nothing is -# found. Also copy "noop.txt" so the COPY instruction copies _something_ to guarantee -# success somehow. -COPY *requirements.txt .devcontainer/noop.txt /tmp/pip-tmp/ +# Uncomment the following COPY line and the corresponding lines in the `RUN` command if you wish to +# include your requirements in the image itself. It is suggested that you only do this if your +# requirements rarely (if ever) change. +# COPY requirements.txt /tmp/pip-tmp/ # Configure apt and install packages RUN apt-get update \ @@ -29,9 +28,9 @@ RUN apt-get update \ # Install pylint && pip --disable-pip-version-check --no-cache-dir install pylint \ # - # Update Python environment based on requirements.txt (if presenet) - && if [ -f "/tmp/pip-tmp/requirements.txt" ]; then pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt; fi \ - && rm -rf /tmp/pip-tmp \ + # Update Python environment based on requirements.txt + # && pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ + # && rm -rf /tmp/pip-tmp \ # # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. && groupadd --gid $USER_GID $USERNAME \ diff --git a/containers/python-3/.devcontainer/devcontainer.json b/containers/python-3/.devcontainer/devcontainer.json index 473993657a..e3f9f41f65 100644 --- a/containers/python-3/.devcontainer/devcontainer.json +++ b/containers/python-3/.devcontainer/devcontainer.json @@ -7,7 +7,7 @@ // "appPort": [], // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "python --version", + // "postCreateCommand": "pip install -r requirements.txt", // Uncomment the next line to use a non-root user. See https://aka.ms/vscode-remote/containers/non-root-user. // "runArgs": [ "-u", "1000" ], diff --git a/containers/python-3/.devcontainer/noop.txt b/containers/python-3/.devcontainer/noop.txt deleted file mode 100644 index 6d257995ff..0000000000 --- a/containers/python-3/.devcontainer/noop.txt +++ /dev/null @@ -1,3 +0,0 @@ -This file is copied into the container along with requirements.txt* from the -parent folder. This is done to prevent the Dockerfile COPY instruction from -failing if no requirements.txt is found. \ No newline at end of file diff --git a/containers/python-3/README.md b/containers/python-3/README.md index c598fc2c7b..5d78812d11 100644 --- a/containers/python-3/README.md +++ b/containers/python-3/README.md @@ -2,9 +2,9 @@ ## Summary -*Develop Python 3 applications. Installs dependencies from your requirements.txt file and the Python extension.* +*Develop Python 3 applications.* -| Metadata | Value | +| Metadata | Value | |----------|-------| | *Contributors* | The [VS Code Python extension](https://marketplace.visualstudio.com/itemdetails?itemName=ms-python.python) team | | *Definition type* | Dockerfile | @@ -12,7 +12,7 @@ ## Using this definition with an existing folder -For convenience, this definition will automatically install dependencies from your `requirements.txt` file when the container is built. Also note that only the integrated terminal is supported by the Remote - Containers extension. You may need to modify `launch.json` configurations to include the following value if an external console is used. +Note that only the integrated terminal is supported by the Remote - Containers extension. You may need to modify `launch.json` configurations to include the following value if an external console is used. ```json "console": "integratedTerminal"