diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..ae5203957bb --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,13 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres +{ + "name": "DefectDojo", + "dockerComposeFile": ["../docker-compose.yml", "../docker-compose.override.dev.yml", "docker-compose.override.dc.yml"], + "service": "uwsgi", + "workspaceFolder": "/app/", + + // Configure tool-specific properties - https://containers.dev/supporting + "customizations": { + "extensions": ["ms-azuretools.vscode-docker", "ms-python.python", "ms-python.debugpy"] + } +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.override.dc.yml b/.devcontainer/docker-compose.override.dc.yml new file mode 100644 index 00000000000..7cca0c725f3 --- /dev/null +++ b/.devcontainer/docker-compose.override.dc.yml @@ -0,0 +1,27 @@ +--- +services: + uwsgi: + entrypoint: ['sleep', 'infinity'] + ports: + - target: 8080 + published: ${DD_PORT:-8080} + protocol: tcp + mode: host + build: + context: ./ + dockerfile: "Dockerfile.django-debian" + target: devcontainer + node-static: + # yarn cleans node_modules, including .gitkeep - alternative to readding it is to configure autoclean/.yarnclean + command: sh -c "yarn; touch node_modules/.gitkeep" + working_dir: /app/components + volumes: + - '.:/app:z' + build: + context: ./ + dockerfile: "Dockerfile.nginx-debian" + target: collectstatic + nginx: + deploy: + # disable nginx - serve static directly from Django + replicas: 0 diff --git a/Dockerfile.django-debian b/Dockerfile.django-debian index 26c27cad391..50f07e00b2d 100644 --- a/Dockerfile.django-debian +++ b/Dockerfile.django-debian @@ -137,5 +137,18 @@ ENV \ DD_UWSGI_NUM_OF_THREADS="2" ENTRYPOINT ["/entrypoint-uwsgi.sh"] +FROM django AS devcontainer + +USER root +RUN usermod -d /home/${appuser} -s /usr/bin/bash ${appuser} \ + && mkdir /home/${appuser} \ + && chown ${appuser}:${appuser} /home/${appuser} + +# do not clean cache as it can be useful in dev +RUN apt update \ + && apt install -y procps + +USER ${appuser} + FROM django AS django-unittests COPY unittests/ ./unittests/