Skip to content

Commit

Permalink
dev tooling: add devcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Nov 7, 2024
1 parent 3f5ee0b commit ba0cc62
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
27 changes: 27 additions & 0 deletions .devcontainer/docker-compose.override.dc.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions Dockerfile.django-debian
Original file line number Diff line number Diff line change
Expand Up @@ -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/

0 comments on commit ba0cc62

Please sign in to comment.