-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Ecalc-1622 setup devcontainer (#624)
Jira issue: Ecalc-1622 * chore: create python devcontainer first version * chore: move poetry env installation from post-create.sh to dockerfile * fix: comment out python interpreter setting not working and set POETRY_VIRTUALENVS_PROMPT * fix: add poetry root package installation in post-create script * docs: add section about devcontainer in readme.md * docs: add ellipsis to spell checker ignore list * chore: add testing related extensions to devcontainer.json * chore: clean up devcontainer extensions and settings
- Loading branch information
Showing
9 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Reference: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/javascript-node | ||
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:18 | ||
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:18 |
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
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,60 @@ | ||
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 related env vars | ||
# Set poetry virtualenv path in writable dir outsde mounted workspace | ||
ENV POETRY_VIRTUALENVS_PATH="$HOME/.venv" | ||
ENV POETRY_VIRTUALENVS_CREATE=true | ||
ENV POETRY_VIRTUALENVS_IN_PROJECT=false | ||
ENV POETRY_VIRTUALENVS_PROMPT='ecalc-py{python_version}' | ||
ENV PIP_DEFAULT_TIMEOUT=100 | ||
|
||
# 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 | ||
|
||
# Set workdir to ecalc project | ||
WORKDIR /workspaces/ecalc | ||
|
||
# Copy essential file (devcontainer setup takes care of other files) | ||
COPY pyproject.toml poetry.lock ./ | ||
|
||
# Install poetry environment without root package | ||
RUN poetry install --no-interaction --no-ansi --no-root |
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,44 @@ | ||
// Github auth: F.ex. use HTTPS auth for github and a git credential manager in your OS to get your git auth working in the container. | ||
{ | ||
"name": "eCalc Python Dev Environment", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "../..", | ||
"args": { | ||
"VARIANT": "3.11-bookworm", | ||
"POETRY_VERSION": "1.8.3", | ||
} | ||
}, | ||
"containerEnv": { | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
// setting python.defaultInterpreterPath is not working as intended, set python interpreter manually. | ||
"python.testing.pytestArgs": [], | ||
"python.testing.cwd": "${workspaceFolder}/src/tests", | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"python.testing.autoTestDiscoverOnSaveEnabled": true, | ||
"python.editor.defaultFormatter": "charliermarsh.ruff", | ||
"ruff.enabled": true, | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
}, | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"github.copilot", | ||
"charliermarsh.ruff", | ||
"shardulm94.trailing-spaces", | ||
"esbenp.prettier-vscode", | ||
"ms-vscode.test-adapter-converter", | ||
"littlefoxteam.vscode-python-test-adapter" | ||
] | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"features": { | ||
"github-cli": "latest" | ||
}, | ||
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder} && bash ./.devcontainer/python/post-create.sh" | ||
} |
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,13 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
set -e | ||
|
||
# Install Pre-commit hooks | ||
echo "Installing Pre-commit hooks..." | ||
pre-commit install | ||
|
||
# Install poetry environment | ||
poetry install | ||
|
||
echo "Post-create script completed successfully." |
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 |
---|---|---|
|
@@ -139,6 +139,9 @@ docs/.docusaurus/ | |
|
||
.DS_store | ||
|
||
# local dev files | ||
.DEV/ | ||
|
||
# generated by "snyk code test" | ||
.dccache | ||
|
||
|
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
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