|
| 1 | +#------------------------------------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. |
| 4 | +#------------------------------------------------------------------------------------------------------------- |
| 5 | + |
| 6 | +FROM python:3 |
| 7 | + |
| 8 | +# Avoid warnings by switching to noninteractive |
| 9 | +ENV DEBIAN_FRONTEND=noninteractive |
| 10 | + |
| 11 | +# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" |
| 12 | +# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs |
| 13 | +# will be updated to match your local UID/GID (when using the dockerFile property). |
| 14 | +# See https://aka.ms/vscode-remote/containers/non-root-user for details. |
| 15 | +ARG USERNAME=vscode |
| 16 | +ARG USER_UID=1000 |
| 17 | +ARG USER_GID=$USER_UID |
| 18 | + |
| 19 | +# Uncomment the following COPY line and the corresponding lines in the `RUN` command if you wish to |
| 20 | +# include your requirements in the image itself. It is suggested that you only do this if your |
| 21 | +# requirements rarely (if ever) change. |
| 22 | +# COPY requirements.txt /tmp/pip-tmp/ |
| 23 | + |
| 24 | +# Configure apt and install packages |
| 25 | +RUN apt-get update \ |
| 26 | + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ |
| 27 | + # |
| 28 | + # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed |
| 29 | + && apt-get -y install git openssh-client iproute2 procps lsb-release \ |
| 30 | + # |
| 31 | + # Install pylint |
| 32 | + && pip --disable-pip-version-check --no-cache-dir install pylint \ |
| 33 | + # |
| 34 | + # Update Python environment based on requirements.txt |
| 35 | + # && pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ |
| 36 | + # && rm -rf /tmp/pip-tmp \ |
| 37 | + # |
| 38 | + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. |
| 39 | + && groupadd --gid $USER_GID $USERNAME \ |
| 40 | + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ |
| 41 | + # [Optional] Add sudo support for the non-root user |
| 42 | + && apt-get install -y sudo \ |
| 43 | + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ |
| 44 | + && chmod 0440 /etc/sudoers.d/$USERNAME \ |
| 45 | + # |
| 46 | + # Clean up |
| 47 | + && apt-get autoremove -y \ |
| 48 | + && apt-get clean -y \ |
| 49 | + && rm -rf /var/lib/apt/lists/* |
| 50 | + |
| 51 | +# Switch back to dialog for any ad-hoc use of apt-get |
| 52 | +ENV DEBIAN_FRONTEND=dialog |
| 53 | + |
| 54 | +# Install Python dependencies from requirements |
| 55 | +COPY requirements.txt requirements_test.txt requirements_dev.txt ./ |
| 56 | + |
| 57 | +RUN pip3 install -r requirements_test.txt; \ |
| 58 | + pip3 install -r requirements_dev.txt; \ |
| 59 | + pip install -Ur requirements.txt; \ |
| 60 | + rm -f requirements.txt requirements_test.txt requirements_dev.txt |
0 commit comments