From 77d2e29fe479a924cfb08e207f25bd73ffd0f24a Mon Sep 17 00:00:00 2001 From: Anand Patel Date: Wed, 28 Feb 2024 23:30:23 +0000 Subject: [PATCH] Add devcontainer configuration --- .devcontainer/Dockerfile | 26 +++++++++++++++++ .devcontainer/devcontainer.json | 27 ++++++++++++++++++ .github/dependabot.yml | 5 ++++ .gitignore | 1 - .vscode/launch.json | 17 ++++++++++++ .vscode/settings.json | 7 +++++ .vscode/tasks.json | 49 +++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..344550718 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,26 @@ +FROM python:3.10-alpine3.18 + +#Install all dependencies. +RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap git yarn + +#Print all logs without buffering it. +ENV PYTHONUNBUFFERED 1 + +#This port will be used by gunicorn. +EXPOSE 8000 + +#This port will be used by vue +EXPOSE 8080 + +#Install all python dependencies to the image +COPY requirements.txt /tmp/pip-tmp/ + +RUN \ + if [ `apk --print-arch` = "armv7" ]; then \ + printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf ; \ + fi +RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev cargo openldap-dev python3-dev && \ + echo -n "INPUT ( libldap.so )" > /usr/lib/libldap_r.so && \ + pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt && \ + rm -rf /tmp/pip-tmp && \ + apk --purge del .build-deps \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..db95c29ec --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +// For format details, see https://aka.ms/devcontainer.json. +{ + "name": "Tandoor Dev Container", + "build": { "context": "..", "dockerfile": "Dockerfile" }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [8000, 8080], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt" + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "ms-python.debugpy", + "ms-python.python" + ] + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5ef2310a3..daf707ca2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,11 @@ version: 2 updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly + - package-ecosystem: "pip" directory: "/" schedule: diff --git a/.gitignore b/.gitignore index 2a977befc..8c3a1d23c 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ data/ /docker-compose.override.yml vue/node_modules plugins -.vscode/ vetur.config.js cookbook/static/vue vue/webpack-stats.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..44a2e0f05 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "args": ["runserver"], + "django": true, + "justMyCode": true + } + ] + } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..1f900399c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "cookbook/tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..3d24c25fb --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,49 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run Migrations", + "type": "shell", + "command": "python3 manage.py migrate", + }, + { + "label": "Run Dev Server", + "type": "shell", + "dependsOn": ["Run Migrations"], + "command": "python3 manage.py runserver", + }, + { + "label": "Yarn Install", + "type": "shell", + "command": "yarn install", + "options": { + "cwd": "${workspaceFolder}/vue" + } + }, + { + "label": "Yarn Serve", + "type": "shell", + "command": "yarn serve", + "dependsOn": ["Yarn Install"], + "options": { + "cwd": "${workspaceFolder}/vue" + } + }, + { + "label": "Yarn Build", + "type": "shell", + "command": "yarn build", + "dependsOn": ["Yarn Install"], + "options": { + "cwd": "${workspaceFolder}/vue" + }, + "group": "build", + }, + { + "label": "Pytest", + "type": "shell", + "command": "python3 -m pytest cookbook/tests", + "group": "test", + } + ] +} \ No newline at end of file