diff --git a/.devcontainer/bashrc b/.devcontainer/bashrc new file mode 100644 index 0000000..730f632 --- /dev/null +++ b/.devcontainer/bashrc @@ -0,0 +1,11 @@ +source /usr/lib/git-core/git-sh-prompt + +# Bash prompt +GIT_PS1_SHOWUNTRACKEDFILES=1 +GIT_PS1_SHOWDIRTYSTATE=1 +if [ $(whoami) = root ]; then + SYMBOL="#" +else + SYMBOL="$" +fi +PS1='\[\033[01;32m\]\u\[\033[0m\] \[\033[1;34m\]\h \[\033[1;35m\]\W\[\033[1;31m\]$(__git_ps1 " (%s)") \[\033[0m\]$SYMBOL ' diff --git a/.devcontainer/dev.Dockerfile b/.devcontainer/dev.Dockerfile new file mode 100644 index 0000000..c89bba5 --- /dev/null +++ b/.devcontainer/dev.Dockerfile @@ -0,0 +1,83 @@ +FROM ghcr.io/mamba-org/micromamba:jammy + +# Take root for the system-wide setup +USER root + +# Install system-wide packages with `apt` +RUN export DEBIAN_FRONTEND=noninteractive && apt update --fix-missing && \ + apt install --no-install-recommends -y \ + ca-certificates \ + moreutils \ + bash-completion \ + less \ + watch \ + git \ + patch \ + git-lfs \ + nano \ + jq \ + gnupg2 \ + openssh-client \ + file \ + htop \ + zip \ + unzip \ + p7zip-full \ + curl \ + wget \ + lsof \ + iputils-ping \ + iproute2 \ + net-tools \ + dnsutils \ + socat \ + telnet \ + && apt clean && rm -rf /var/lib/apt/lists/* + +# Install bash completions +RUN mkdir -p /etc/bash_completion.d \ + && sh -c "curl -L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose" \ + && sh -c "curl -L https://raw.githubusercontent.com/docker/cli/v20.10.13/contrib/completion/bash/docker > /etc/bash_completion.d/docker" \ + && sh -c "curl -L https://raw.githubusercontent.com/git/git/v2.35.1/contrib/completion/git-completion.bash > /etc/bash_completion.d/git" + +# Make sure everyone can access the workspaces directory. +ENV WORKSPACES_DIR="/workspaces" +RUN : \ + && mkdir --parents --mode=777 "${WORKSPACES_DIR}" \ + && chown "$MAMBA_USER:$MAMBA_USER" "${WORKSPACES_DIR}" + +# Sane defaults for Git +RUN : \ + # Switch default editor from vim to nano + && git config --system core.editor nano \ + # Prevent unintentional merges + # + && git config --system pull.ff only \ + # Use default branch name "main" instead of "master" + && git config --system init.defaultBranch main \ + # Initialize Git LFS + && git lfs install --system --skip-repo \ + ; + +# Go back to regular user +USER $MAMBA_USER + +# Install git prompt +# NOTE(hadim): likely a bit hacky +COPY --chown=$MAMBA_USER:$MAMBA_USER .devcontainer/bashrc /tmp/bashrc +RUN cat /tmp/bashrc >> ~/.bashrc + +# Install the Conda packages +ARG CONDA_ENV_FILE +COPY --chown=$MAMBA_USER:$MAMBA_USER ${CONDA_ENV_FILE} /tmp/${CONDA_ENV_FILE} +RUN micromamba install --yes --name base --file /tmp/${CONDA_ENV_FILE} \ + && micromamba clean --all --yes + +# Activate the conda environment for the Dockerfile. +# +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +# Create and set the workspace folder +ARG CONTAINER_WORKSPACE_FOLDER=/workspaces/default-workspace-folder +RUN mkdir -p "${CONTAINER_WORKSPACE_FOLDER}" +WORKDIR "${CONTAINER_WORKSPACE_FOLDER}" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..96e2af8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,71 @@ +{ + "name": "medchem", + "containerEnv": { + "TZ": "America/Montreal", + "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}", + "CONTAINER_WORKSPACE_FOLDER": "${containerWorkspaceFolder}" + }, + "remoteUser": "mambauser", + "runArgs": [ + "--hostname", + "devcontainer" + // // Warning: loading .env into the environment will undermine the ability + // // to use .env to dynamically adjust the unspecified values. + // "--env-file", ".env" + ], + "build": { + "dockerfile": "dev.Dockerfile", + "context": "../", + "args": { + "CONTAINER_WORKSPACE_FOLDER": "${containerWorkspaceFolder}", + "CONDA_ENV_FILE": "env.yml" + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [], + // allow the entrypoint to run + // "overrideCommand": false, + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pip install -e .", + // Customize the way VS Code is started when running in the container + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-toolsai.jupyter", + "ms-azuretools.vscode-docker", + "ms-vsliveshare.vsliveshare", + "donjayamanne.githistory", + "mutantdino.resourcemonitor", + "github.copilot", + "davidanson.vscode-markdownlint" + ], + "settings": { + // Disable telemetry + "telemetry.enableTelemetry": false, + // For linting (code format checking), disable pylint and enable + // pydocstyle for docstrings and flake8 for code. + "python.linting.pylintEnabled": false, + "python.linting.pydocstyleEnabled": false, + "python.linting.flake8Enabled": false, + // Turn on "black" for automatic code formatting + "python.formatting.provider": "black", + // Disable barely usable scrollbar + "workbench.editor.wrapTabs": true, + // Use Pylance + "python.languageServer": "Pylance", + "python.analysis.typeCheckingMode": "basic", + // Path of the default Python environment + "python.pythonPath": "/opt/conda/bin/python", + "python.defaultInterpreterPath": "/opt/conda/bin/python", + // Disable the "conda activate base" command when opening a new terminal + "python.terminal.activateEnvironment": false, + // Make sure that key combos like Ctrl+K are not intercepted by VS Code + // when using the terminal + "terminal.integrated.allowChords": false, + "terminal.integrated.inheritEnv": false + } + } + } +}