Skip to content

Commit

Permalink
Add devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
dukeofphilberg committed Aug 8, 2024
1 parent 68b43c5 commit 00e5105
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"dockerFile": "../Dockerfile.dev",
"postCreateCommand": ".devcontainer/postcreate",
"postStartCommand": ".devcontainer/poststart",
"customizations": {
"vscode": {
"extensions": [
"charliermarsh.ruff",
"ms-python.pylint",
"ms-python.vscode-pylance",
"esbenp.prettier-vscode",
"GitHub.copilot"
],
"settings": {
"python.defaultInterpreterPath": "/home/vscode/.venv/bin/python",
"python.pythonPath": "/home/vscode/.venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.defaultProfile.linux": "zsh",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
}
}
}
22 changes: 22 additions & 0 deletions .devcontainer/postcreate
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

cd "$(dirname "$0")/.."

if [ ! -n "$VIRTUAL_ENV" ]; then
if [ -x "$(command -v uv)" ]; then
uv venv .venv
else
python3 -m venv .venv
fi
source .venv/bin/activate
fi

if ! [ -x "$(command -v uv)" ]; then
python3 -m pip install uv
fi

.devcontainer/poststart

#pre-commit install
uv pip install -e .
7 changes: 7 additions & 0 deletions .devcontainer/poststart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

cd "$(dirname "$0")/.."

uv pip install -r requirements.txt --upgrade
uv pip install -r requirements_dev.txt --upgrade
9 changes: 9 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.12

# Install uv
RUN pip3 install uv

USER vscode
ENV VIRTUAL_ENV="/home/vscode/.venv"
RUN uv venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

0 comments on commit 00e5105

Please sign in to comment.