Improve devcontainer and configure VSCode debugging (#1060)

This commit is contained in:
Daniel Palstra 2022-03-16 17:37:56 +01:00 committed by GitHub
parent 960378b213
commit 86b450fb8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 47 deletions

View File

@ -10,21 +10,24 @@ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/
# install poetry - respects $POETRY_VERSION & $POETRY_HOME # install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN echo "export PROMPT_COMMAND='history -a'" >> /home/vscode/.bashrc \
&& echo "export HISTFILE=~/commandhistory/.bash_history" >> /home/vscode/.bashrc \
&& chown vscode:vscode -R /home/vscode/
ENV PYTHONUNBUFFERED=1 \ ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \ PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \ PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \ PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \ POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \ POETRY_VIRTUALENVS_CREATE=false
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
# prepend poetry and venv to path # prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" ENV PATH="$POETRY_HOME/bin:$PATH"
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
# RUN poetry config virtualenvs.create false
RUN apt-get update \ RUN apt-get update \
&& apt-get install --no-install-recommends -y \ && apt-get install --no-install-recommends -y \
@ -32,7 +35,6 @@ RUN apt-get update \
build-essential \ build-essential \
libpq-dev \ libpq-dev \
libwebp-dev \ libwebp-dev \
# LDAP Dependencies
libsasl2-dev libldap2-dev libssl-dev \ libsasl2-dev libldap2-dev libssl-dev \
gnupg gnupg2 gnupg1 \ gnupg gnupg2 gnupg1
&& pip install -U --no-cache-dir pip # && pip install -U --no-cache-dir pip

View File

@ -14,7 +14,10 @@
"NODE_VERSION": "16" "NODE_VERSION": "16"
} }
}, },
"mounts": [
"source=mealie-devcontainer-workspace,target=/workspaces/mealie/frontend/node_modules,type=volume",
"source=mealie-bashhistory,target=/home/vscode/commandhistory,type=volume"
],
// Set *default* container specific settings.json values on container create. // Set *default* container specific settings.json values on container create.
"settings": { "settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python", "python.defaultInterpreterPath": "/usr/local/bin/python",
@ -30,19 +33,21 @@
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
}, },
// Add the IDs of extensions you want installed when the container is created. // Add the IDs of extensions you want installed when the container is created.
"extensions": ["ms-python.python", "ms-python.vscode-pylance"], "extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 9000], "forwardPorts": [
3000,
9000
],
// Use 'postCreateCommand' to run commands after the container is created. // Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "make setup", "postCreateCommand": "sudo chown -R vscode:vscode /workspaces/mealie/frontend/node_modules && make setup",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode", "remoteUser": "vscode",
"features": { // "features": {
"git": "latest" // "git": "latest"
} // }
} }

View File

@ -5,7 +5,7 @@ repos:
- id: check-yaml - id: check-yaml
exclude: "mkdocs.yml" exclude: "mkdocs.yml"
- id: check-json - id: check-json
exclude: "devcontainer.json" exclude: (.vscode|.devcontainer)
- id: check-toml - id: check-toml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace

30
.vscode/launch.json vendored
View File

@ -5,29 +5,21 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Python: FastAPI", "name": "Mealie Backend",
"type": "python", "type": "python",
"request": "launch", "request": "launch",
"module": "uvicorn", "module": "uvicorn",
"args": ["mealie.app:app"], "args": [
"mealie.app:app",
"--port",
"9000"
],
"env": {
"PRODUCTION": "False",
},
"justMyCode": false, "justMyCode": false,
"jinja": true "jinja": true,
}, "preLaunchTask": "Init Database"
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false,
"env": { "PYTEST_ADDOPTS": "--no-cov" }
} }
] ]
} }

31
.vscode/settings.json vendored
View File

@ -5,7 +5,11 @@
"backend", "backend",
"code-generation" "code-generation"
], ],
"cSpell.enableFiletypes": ["!javascript", "!python", "!yaml"], "cSpell.enableFiletypes": [
"!javascript",
"!python",
"!yaml"
],
"cSpell.words": [ "cSpell.words": [
"chowdown", "chowdown",
"compression", "compression",
@ -20,7 +24,9 @@
"source.organizeImports": false "source.organizeImports": false
}, },
"editor.formatOnSave": true, "editor.formatOnSave": true,
"eslint.workingDirectories": ["./frontend"], "eslint.workingDirectories": [
"./frontend"
],
"files.exclude": { "files.exclude": {
"**/__pycache__": true, "**/__pycache__": true,
"**/.DS_Store": true, "**/.DS_Store": true,
@ -29,7 +35,9 @@
"**/.svn": true, "**/.svn": true,
"**/CVS": true "**/CVS": true
}, },
"i18n-ally.enabledFrameworks": ["vue"], "i18n-ally.enabledFrameworks": [
"vue"
],
"i18n-ally.keystyle": "nested", "i18n-ally.keystyle": "nested",
"i18n-ally.localesPaths": "frontend/lang/messages", "i18n-ally.localesPaths": "frontend/lang/messages",
"i18n-ally.sourceLanguage": "en-US", "i18n-ally.sourceLanguage": "en-US",
@ -37,9 +45,13 @@
"python.linting.enabled": true, "python.linting.enabled": true,
"python.linting.flake8Enabled": true, "python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": false, "python.linting.pylintEnabled": false,
"python.linting.pylintArgs": ["--rcfile=${workspaceFolder}/.pylintrc"], "python.linting.pylintArgs": [
"--rcfile=${workspaceFolder}/.pylintrc"
],
"python.testing.autoTestDiscoverOnSaveEnabled": false, "python.testing.autoTestDiscoverOnSaveEnabled": false,
"python.testing.pytestArgs": ["tests"], "python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true, "python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false, "python.testing.unittestEnabled": false,
"python.analysis.typeCheckingMode": "basic", "python.analysis.typeCheckingMode": "basic",
@ -47,5 +59,12 @@
"python.sortImports.path": "${workspaceFolder}/.venv/bin/isort", "python.sortImports.path": "${workspaceFolder}/.venv/bin/isort",
"search.mode": "reuseEditor", "search.mode": "reuseEditor",
"vetur.validation.template": false, "vetur.validation.template": false,
"coverage-gutters.lcovname": "${workspaceFolder}/.coverage" "coverage-gutters.lcovname": "${workspaceFolder}/.coverage",
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test_*.py"
]
} }

18
.vscode/tasks.json vendored
View File

@ -6,7 +6,9 @@
"command": "make docker-dev", "command": "make docker-dev",
"type": "shell", "type": "shell",
"args": [], "args": [],
"problemMatcher": ["$tsc"], "problemMatcher": [
"$tsc"
],
"presentation": { "presentation": {
"reveal": "always" "reveal": "always"
}, },
@ -17,7 +19,9 @@
"command": "make docker-prod", "command": "make docker-prod",
"type": "shell", "type": "shell",
"args": [], "args": [],
"problemMatcher": ["$tsc"], "problemMatcher": [
"$tsc"
],
"presentation": { "presentation": {
"reveal": "always" "reveal": "always"
}, },
@ -33,6 +37,16 @@
}, },
"problemMatcher": [] "problemMatcher": []
}, },
{
"label": "Init Database",
"command": "poetry run python mealie/db/init_db.py",
"type": "shell",
"presentation": {
"reveal": "always",
"group": "groupA"
},
"problemMatcher": []
},
{ {
"label": "Dev: Start Frontend", "label": "Dev: Start Frontend",
"command": "make frontend", "command": "make frontend",