Skip to content

Commit 61a306f

Browse files
authored
Add devcontainer definition files
1 parent 9c4609d commit 61a306f

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 condaforge/mambaforge
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+
# Copy environment.yml (if found) to a temp locaition so we update the environment. Also
20+
# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists.
21+
COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/
22+
23+
# Configure apt and install packages
24+
RUN apt-get update \
25+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
26+
#
27+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
28+
&& apt-get -y install git openssh-client less iproute2 procps iproute2 lsb-release \
29+
#
30+
# Install pylint
31+
&& /opt/conda/bin/pip install pylint \
32+
#
33+
# Update Python environment based on environment.yml (if present)
34+
&& if [ -f "/tmp/conda-tmp/environment.yml" ]; then /opt/conda/bin/mamba env update -n base -f /tmp/conda-tmp/environment.yml; fi \
35+
&& rm -rf /tmp/conda-tmp \
36+
#
37+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
38+
&& groupadd --gid $USER_GID $USERNAME \
39+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
40+
# [Optional] Add sudo support for the non-root user
41+
&& apt-get install -y sudo \
42+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
43+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
44+
# [Additional Customization]
45+
&& apt-get install -y nano vim emacs \
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

.devcontainer/devcontainer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/python-3-miniconda
3+
{
4+
"name": "pandas-flavor dev container",
5+
// "context": "..",
6+
// "image": "registry.hub.docker.com/ericmjl/pyjanitor:devcontainer",
7+
"build": {
8+
"dockerfile": "Dockerfile",
9+
"context": ".."
10+
},
11+
// Set *default* container specific settings.json values on container create.
12+
"settings": {
13+
"terminal.integrated.defaultProfile.linux": "bash",
14+
"python.defaultInterpreterPath": "/opt/conda/bin/python",
15+
"python.linting.enabled": true,
16+
"python.linting.pylintEnabled": true,
17+
"python.linting.pylintPath": "/opt/conda/bin/pylint",
18+
"python.formatting.provider": "black",
19+
"python.formatting.blackArgs": [
20+
"--config",
21+
"pyproject.toml",
22+
],
23+
"editor.formatOnSave": true,
24+
"files.insertFinalNewline": true,
25+
"files.trimFinalNewlines": true,
26+
"files.trimTrailingWhitespace": true,
27+
"[python]": {
28+
"editor.formatOnSaveMode": "file",
29+
},
30+
},
31+
// Add the IDs of extensions you want installed when the container is created.
32+
"extensions": [
33+
"ms-python.python",
34+
"ms-python.vscode-pylance",
35+
"ms-vsliveshare.vsliveshare-pack",
36+
"arcticicestudio.nord-visual-studio-code"
37+
],
38+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
39+
"forwardPorts": [
40+
8000
41+
],
42+
// Use 'postCreateCommand' to run commands after the container is created.
43+
"postCreateCommand": "pre-commit install --install-hooks && python setup.py develop"
44+
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
45+
// "remoteUser": "vscode"
46+
}

.devcontainer/noop.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file is copied into the container along with environment.yml* from the
2+
parent folder. This is done to prevent the Dockerfile COPY instruction from
3+
failing if no environment.yml is found.

environment.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: pandas-flavor
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.9
6+
- pandas>=0.23
7+
- xarray
8+
- pip
9+
- pip:
10+
- lazy-loader

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.black]
2+
line-length = 88
3+
target-version = ['py39']
4+
include = '\.pyi?$'
5+
extend-exclude = '''
6+
# A regex preceded with ^/ will apply only to files and directories
7+
# in the root of the project.
8+
^/foo.py # exclude a file named foo.py in the root of the project (in addition to the defaults)
9+
'''

0 commit comments

Comments
 (0)