Skip to content

Commit

Permalink
feat: working version of a devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
d0choa committed Dec 7, 2023
1 parent a684d12 commit f5ea847
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 141 deletions.
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

ENV POETRY_HOME="/home/vscode/.poetry"
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
ENV POETRY_VERSION=1.7.1

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
htop \
fzf \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

COPY pyproject.toml poetry.lock ./
RUN pipx install poetry==${POETRY_VERSION}

# Add fzf to .zshrc
RUN echo "source /usr/share/doc/fzf/examples/key-bindings.zsh" >> /home/vscode/.zshrc
RUN echo "source /usr/share/doc/fzf/examples/completion.zsh" >> /home/vscode/.zshrc
73 changes: 73 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "OTGdev",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.10-bullseye",
"POETRY_VERSION": "1.7.1"
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.10"
},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
"source=devcontainer-bashhistory,target=/commandhistory,type=volume",
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached"
],
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
"customizations": {
"vscode": {
"extensions": [
"charliermarsh.ruff",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.black-formatter",
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"eamodio.gitlens",
"ms-azuretools.vscode-docker",
"github.vscode-github-actions",
"timonwong.shellcheck",
"GitHub.copilot",
"vivaxy.vscode-conventional-commits",
"ms-vscode-remote.remote-ssh",
"ms-toolsai.jupyter",
"ms-vscode.makefile-tools"
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"workbench.startupEditor": "readme",
"terminal.integrated.fontFamily": "Fira Code",
"terminal.integrated.defaultProfile.linux": "zsh",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": false,
"source.organizeImports": true
}
},
"python.terminal.launchArgs": ["-m", "IPython", "--no-autoindent"],
"isort.args": ["--profile", "black"],
"python.testing.pytestArgs": [".", "--doctest-modules", "--cov=src/"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"mypy-type-checker.severity": {
"error": "Information"
},
"ruff.fixAll": false,
"ruff.organizeImports": false
}
}
}
}
7 changes: 7 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Install Poetry environment
poetry install --no-interaction --no-root --no-cache

# Install Pre-commit hooks
poetry run pre-commit install --install-hooks
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ repos:
- id: check-json
- id: check-toml
- id: check-yaml
- id: pretty-format-json
args:
- --autofix
- --no-ensure-ascii
- --no-sort-keys
- id: check-ast
- id: debug-statements
- id: check-docstring-first
Expand Down
18 changes: 4 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnPaste": false,
Expand All @@ -8,11 +9,7 @@
"source.organizeImports": true
}
},
"python.terminal.launchArgs": [
"-m",
"IPython",
"--no-autoindent"
],
"python.terminal.launchArgs": ["-m", "IPython", "--no-autoindent"],
"[jsonc]": {
"editor.tabSize": 2,
"editor.insertSpaces": true,
Expand All @@ -23,16 +20,9 @@
}
},
"json.format.keepLines": true,
"isort.args": [
"--profile",
"black"
],
"isort.args": ["--profile", "black"],
"autoDocstring.docstringFormat": "google",
"python.testing.pytestArgs": [
".",
"--doctest-modules",
"--cov=src/"
],
"python.testing.pytestArgs": [".", "--doctest-modules", "--cov=src/"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"mypy-type-checker.severity": {
Expand Down
Loading

0 comments on commit f5ea847

Please sign in to comment.