-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create python devcontainer first version
- Loading branch information
Showing
6 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ | |
"git": "latest", | ||
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
ARG VARIANT="3.11-bookworm" | ||
FROM mcr.microsoft.com/devcontainers/python:${VARIANT} | ||
|
||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ARG POETRY_VERSION=1.8.3 | ||
ARG POETRY_VIRTUALENVS_PATH | ||
ENV USER=vscode | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update \ | ||
&& apt-get install -y build-essential --no-install-recommends make \ | ||
ca-certificates \ | ||
git \ | ||
libssl-dev \ | ||
zlib1g-dev \ | ||
libbz2-dev \ | ||
libreadline-dev \ | ||
libsqlite3-dev \ | ||
wget \ | ||
curl \ | ||
llvm \ | ||
libncurses5-dev \ | ||
xz-utils \ | ||
tk-dev \ | ||
libxml2-dev \ | ||
libxmlsec1-dev \ | ||
libffi-dev \ | ||
liblzma-dev \ | ||
default-jre | ||
|
||
# Set non-root user | ||
USER $USER | ||
ENV HOME="/home/$USER" | ||
ENV PATH="${HOME}/.local/bin:$PATH" | ||
|
||
# Set poetry virtualenv path in writable dir outsde mounted workspace | ||
ENV POETRY_VIRTUALENVS_PATH="$HOME/.venv" | ||
|
||
# Python and poetry installation | ||
RUN echo $(which python) && echo $(which python3) \ | ||
&& python3 -m pip install --upgrade pip pipx \ | ||
&& pipx install "poetry==${POETRY_VERSION}" \ | ||
&& pip install pre-commit \ | ||
&& poetry --version \ | ||
&& pre-commit --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "eCalc Python Dev Environment", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "../..", | ||
"args": { | ||
"VARIANT": "3.11-bookworm", | ||
"POETRY_VERSION": "1.8.3", | ||
} | ||
}, | ||
"containerEnv": { | ||
"POETRY_VIRTUALENVS_CREATE": "true", | ||
"POETRY_VIRTUALENVS_IN_PROJECT": "false", | ||
"PIP_DEFAULT_TIMEOUT": "100", | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"python.defaultInterpreterPath": "${containerEnv:POETRY_VIRTUALENVS_PATH}/bin/python", | ||
"python.testing.pytestArgs": [], | ||
"python.testing.cwd": "${workspaceFolder}/src/tests", | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"python.testing.autoTestDiscoverOnSaveEnabled": true, | ||
"ruff.enabled": true, | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"[python]": { | ||
"editor.defaultFormatter": "charliermarsh.ruff" | ||
} | ||
}, | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"github.copilot", | ||
"eamodio.gitlens", | ||
"charliermarsh.ruff", | ||
"shardulm94.trailing-spaces", | ||
] | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"features": { | ||
"github-cli": "latest" | ||
}, | ||
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder} && bash ./.devcontainer/python/post-create.sh", | ||
// "mounts": [ | ||
// // TODO: Reuse poetry cache between builds | ||
// "source=,target=/home/vscode/.cache/pypoetry,type=bind,consistency=cached" | ||
// ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
set -e | ||
|
||
# Install Poetry dependencies | ||
echo "Installing Poetry dependencies..." | ||
poetry install | ||
|
||
# Install Pre-commit hooks | ||
echo "Installing Pre-commit hooks..." | ||
pre-commit install | ||
|
||
echo "Post-create script completed successfully." |