-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: Create DockerFile and devcontainer.json files to work with Docker and VS Code in Containers #30638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Create DockerFile and devcontainer.json files to work with Docker and VS Code in Containers #30638
Changes from 7 commits
9ba699f
db62191
eb3c32f
5cc8ab2
e454780
b282552
36d3882
0a63154
aa7d0dc
851ea92
76a6b7c
19f4893
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at | ||
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3-miniconda | ||
{ | ||
"name": "Pandas", | ||
"context": ".", | ||
"dockerFile": "Dockerfile", | ||
|
||
// Use 'settings' to set *default* container specific settings.json values on container create. | ||
// You can edit these settings after create using File > Preferences > Settings > Remote. | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"python.condaPath": "/opt/conda/bin/conda", | ||
"python.pythonPath": "/opt/conda/bin/python", | ||
"python.formatting.provider": "black", | ||
"python.linting.enabled": true, | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.mypyEnabled": true, | ||
"python.testing.pytestEnabled": true | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created in the array below. | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-vscode.cpptools" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM continuumio/miniconda3 | ||
|
||
# if you forked pandas, you can pass in your own GitHub username to use your fork | ||
# i.e. gh_username=myname | ||
ARG gh_username=pandas-dev | ||
ARG pandas_home="/home/pandas" | ||
|
||
# Avoid warnings by switching to noninteractive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# 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 iproute2 lsb-release \ | ||
# | ||
# Install C compilers (gcc not enough, so just went with build-essential which admittedly might be overkill), | ||
# needed to build pandas C extensions | ||
&& apt-get -y install build-essential \ | ||
# | ||
# cleanup | ||
&& 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 | ||
|
||
# Clone pandas repo | ||
RUN mkdir "$pandas_home" \ | ||
&& git clone "https://github.com/$gh_username/pandas.git" "$pandas_home" \ | ||
&& cd "$pandas_home" \ | ||
&& git remote add upstream "https://github.com/pandas-dev/pandas.git" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you pull from upstream master after this step? Should keep up with the latest changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just did There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm don't see this in the diff. Should be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I thought you meant on my changes in the PR, lol, not in the DockerFile. got it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @WillAyd is requesting that the Dockerfile has a Though I'm not sure that would achieve the desired effect, since it only happens when the docker image is built. How often does that happen? How does a person starting up a container ensure they're working with a fresh copy of pandas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest, the main use case is setting up a fresh env for some dev work, using this But the real value of this is that's it's dead simple to delete and create a new env in VS Online or with containers, so the usual use case is just to create a new env and not use an existing one for a while. So I guess this line is indeed unnecessary, and I should remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me know if you agree before I revert that commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think either this should stay or should remove the build step later. Doesn't make sense to build an outdated version for development There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure I follow you there. this is the same steps as the instructions in the main docs. Even if we remove |
||
|
||
# Because it is surprisingly difficult to activate a conda environment inside a DockerFile | ||
# (from personal experience and per https://github.com/ContinuumIO/docker-images/issues/89), | ||
# we just update the base/root one from the 'environment.yml' file instead of creating a new one. | ||
gfyoung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# Set up environment | ||
RUN conda env update -n base -f "$pandas_home/environment.yml" | ||
|
||
# Build C extensions and pandas | ||
RUN cd "$pandas_home" \ | ||
&& python setup.py build_ext --inplace -j 4 \ | ||
&& python -m pip install -e . |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,17 @@ requires a C compiler and Python environment. If you're making documentation | |
changes, you can skip to :ref:`contributing.documentation` but you won't be able | ||
to build the documentation locally before pushing your changes. | ||
|
||
Using a Docker Container | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Instead of manually setting up a development environment, you can use Docker to | ||
automatically create the environment with just several commands. Pandas provides a `DockerFile` | ||
in the root directory to build a Docker image with a full pandas development environment. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth linking the docker installation guide in this section There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where's that? I never saw a docker section. |
||
|
||
Even easier, you can use the DockerFile to launch a remote session with Visual Studio Code, | ||
a popular free IDE, using the `.devcontainer.json` file. | ||
See https://code.visualstudio.com/docs/remote/containers for details. | ||
|
||
.. _contributing.dev_c: | ||
|
||
Installing a C compiler | ||
|
Uh oh!
There was an error while loading. Please reload this page.