Update to use Python pre-built image
This commit is contained in:
@@ -3,60 +3,36 @@
|
||||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
FROM python:3
|
||||
# Update the VARIANT arg in devcontainer.json to pick a Python version: 3, 3.8, 3.7, 3.6
|
||||
# To fully customize the contents of this image, use the following Dockerfile instead:
|
||||
# https://github.com/microsoft/vscode-dev-containers/tree/v0.109.0/containers/python-3/.devcontainer/base.Dockerfile
|
||||
ARG VARIANT=3
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
|
||||
|
||||
# Avoid warnings by switching to noninteractive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
|
||||
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
|
||||
# will be updated to match your local UID/GID (when using the dockerFile property).
|
||||
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
|
||||
ENV PIP_TARGET=/usr/local/share/pip-global
|
||||
ENV PYTHONPATH=${PYTHONPATH}:${PIP_TARGET}
|
||||
ENV PATH=${PATH}:${PIP_TARGET}/bin
|
||||
|
||||
# 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.
|
||||
# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
|
||||
#
|
||||
# COPY requirements.txt /tmp/pip-tmp/
|
||||
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
|
||||
# && rm -rf /tmp/pip-tmp
|
||||
|
||||
# Configure apt and install packages
|
||||
RUN apt-get update \
|
||||
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
|
||||
#
|
||||
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
|
||||
&& apt-get -y install git iproute2 procps lsb-release \
|
||||
#
|
||||
# Install pylint
|
||||
&& pip --disable-pip-version-check --no-cache-dir install pylint \
|
||||
#
|
||||
# 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 \
|
||||
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
||||
# [Optional] Add sudo support for the non-root user
|
||||
&& apt-get install -y sudo \
|
||||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
|
||||
&& chmod 0440 /etc/sudoers.d/$USERNAME \
|
||||
#
|
||||
# Create alternate global install location that both uses have rights to access
|
||||
&& mkdir -p /usr/local/share/pip-global \
|
||||
&& chown ${USERNAME}:root /usr/local/share/pip-global \
|
||||
#
|
||||
# Clean up
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Switch back to dialog for any ad-hoc use of apt-get
|
||||
ENV DEBIAN_FRONTEND=dialog
|
||||
|
||||
# [Optional] Create alternate global install location where the vscode user can write w/o sudo
|
||||
ENV PIP_TARGET=/usr/local/pip-global
|
||||
ENV PYTHONPATH=${PIP_TARGET}:${PYTHONPATH}
|
||||
ENV PATH=${PIP_TARGET}/bin:${PATH}
|
||||
RUN mkdir -p ${PIP_TARGET} \
|
||||
&& chown vscode:root ${PIP_TARGET} \
|
||||
&& export SNIPPET="if [ \"\$(stat -c '%U' ${PIP_TARGET})\" != \"vscode\" ]; then chown -R vscode:root ${PIP_TARGET}; fi" \
|
||||
&& echo "$SNIPPET" | tee -a /root/.bashrc >> /home/vscode/.bashrc \
|
||||
&& echo "$SNIPPET" | tee -a /root/.zshrc >> /home/vscode/.zshrc
|
||||
|
||||
# [Optional] Uncomment this section to install additional packages.
|
||||
#
|
||||
# ENV DEBIAN_FRONTEND=noninteractive
|
||||
# RUN apt-get update \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here> \
|
||||
# #
|
||||
# # Clean up
|
||||
# && apt-get autoremove -y \
|
||||
# && apt-get clean -y \
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
# ENV DEBIAN_FRONTEND=dialog
|
||||
|
||||
Reference in New Issue
Block a user